add error messages and new plugin
parent
7ae31049a0
commit
8eab2c90bb
|
@ -20,8 +20,9 @@ async def _(event):
|
|||
await event.edit("process returned {}\n output: {}".format(exc.returncode, exc.output))
|
||||
else:
|
||||
x_reponse = t_response.decode("UTF-8")
|
||||
final_output = "**EXEC**: {} \n\n **OUTPUT**: \n{} \n".format(input_str, x_reponse)
|
||||
try:
|
||||
await event.edit(x_reponse)
|
||||
await event.edit(final_output)
|
||||
except MessageEmptyError as exc:
|
||||
await event.edit("✅ Exited correctly.")
|
||||
|
||||
|
|
|
@ -26,12 +26,17 @@ async def _(event):
|
|||
end = datetime.now()
|
||||
ms = (end - start).seconds
|
||||
await event.edit("Downloaded to {} in {} seconds.".format(downloaded_file_name, ms))
|
||||
start = datetime.now()
|
||||
media_urls = upload_file(downloaded_file_name)
|
||||
end = datetime.now()
|
||||
ms = (end - start).seconds
|
||||
os.remove(downloaded_file_name)
|
||||
await event.edit("Uploaded to {} in {} seconds.".format(media_urls[0], ms))
|
||||
try:
|
||||
start = datetime.now()
|
||||
media_urls = upload_file(downloaded_file_name)
|
||||
except TelegraphException as e:
|
||||
await event.edit("ERROR: " + str(e))
|
||||
os.remove(downloaded_file_name)
|
||||
else:
|
||||
end = datetime.now()
|
||||
ms = (end - start).seconds
|
||||
os.remove(downloaded_file_name)
|
||||
await event.edit("Uploaded to {} in {} seconds.".format(media_urls[0], ms))
|
||||
else:
|
||||
await event.edit("Reply to a message to get a permanent telegra.ph link. (Inspired by @ControllerBot)")
|
||||
|
||||
|
@ -57,8 +62,7 @@ def upload_file(f):
|
|||
error = response.get('error')
|
||||
|
||||
if error:
|
||||
# raise TelegraphException(error)
|
||||
pass
|
||||
raise TelegraphException(error)
|
||||
|
||||
return ["https://telegra.ph" + i['src'] for i in response]
|
||||
|
||||
|
@ -115,3 +119,6 @@ class FilesOpener(object):
|
|||
|
||||
self.opened_files = []
|
||||
|
||||
|
||||
class TelegraphException(Exception):
|
||||
pass
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from telethon import events
|
||||
|
||||
|
||||
@borg.on(events.NewMessage(pattern=r".shrug", outgoing=True))
|
||||
async def _(event):
|
||||
if event.fwd_from:
|
||||
return
|
||||
await event.edit("¯\_(ツ)_/¯")
|
||||
|
Reference in New Issue