aboutsummaryrefslogtreecommitdiff
path: root/modules/telegram.py
diff options
context:
space:
mode:
authorGravatar dngfx2018-08-31 10:51:47 +0100
committerGravatar dngfx2018-08-31 10:51:47 +0100
commit90ce92dc39395444862edfc7946ef7a1195f2464 (patch)
tree6832c146a15879df292d265083bfe5795cbdfa69 /modules/telegram.py
parentReformat (diff)
Revert "Reformat"
This reverts commit abed9cf
Diffstat (limited to 'modules/telegram.py')
-rw-r--r--modules/telegram.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/modules/telegram.py b/modules/telegram.py
index c970fd46..cecbd16e 100644
--- a/modules/telegram.py
+++ b/modules/telegram.py
@@ -5,7 +5,6 @@ import json
from datetime import datetime
from threading import Thread
-
class Module(Thread):
_name = "telegram"
@@ -27,8 +26,7 @@ class Module(Thread):
dolphin.events.on("signal").on("interrupt").hook(self.sigint)
def start(self, bot, update):
- bot.send_message(chat_id=update.message.chat_id,
- text="`Dolphin, but Telegram`", parse_mode="Markdown")
+ bot.send_message(chat_id=update.message.chat_id, text="`Dolphin, but Telegram`", parse_mode="Markdown")
def handle(self, bot, update):
message, text = update.message, update.message.text
@@ -46,24 +44,19 @@ class Module(Thread):
"stdout": IOWrapper(bot, message.chat_id, message.message_id),
"stderr": IOWrapper(bot, message.chat_id, message.message_id),
"external": True,
- }
- self.dolphin.events.on("telegram").on("command").on(command).call(
- **data)
+ }
+ self.dolphin.events.on("telegram").on("command").on(command).call(**data)
def sigint(self, event):
self.updater.stop()
-
class IOWrapper:
def __init__(self, bot, chat_id, message_id):
self.bot = bot
self.chat_id = chat_id
self.message_id = message_id
-
def write(self, text):
- if len(text) > 4096 - 10:
+ if len(text)>4096-10:
text = text[:4086] + "…"
- self.bot.send_message(chat_id=self.chat_id,
- text="```\n" + text + "\n```",
- reply_to_message_id=self.message_id,
- parse_mode="Markdown")
+ self.bot.send_message(chat_id=self.chat_id, text="```\n" + text + "\n```",
+ reply_to_message_id=self.message_id, parse_mode="Markdown")