Remove telegram functionality - it's very broken/outdated and needs a

complete rewrite
This commit is contained in:
jesopo 2018-12-05 15:53:49 +00:00
parent a8cb500784
commit dd0c5093a0
4 changed files with 0 additions and 68 deletions

View file

@ -4,7 +4,6 @@ Python3 event-driven modular IRC bot!
## Dependencies
* [BeautifulSoup4](https://pypi.python.org/pypi/beautifulsoup4)
* [Flask](https://pypi.org/project/Flask/)
* [python-telegram-bot](https://pypi.org/project/python-telegram-bot/)
* [requests](https://pypi.org/project/requests/)
* [scrypt](https://pypi.python.org/pypi/scrypt)
* [suds](https://pypi.python.org/pypi/suds-jurko)

View file

@ -113,7 +113,6 @@ class Module(ModuleManager.BaseModule):
def reduced_activities(self, string): return [a for a in self.activities(string) if a in self.PASSENGER_ACTIVITIES]
@utils.hook("telegram.command.nrtrains")
@utils.hook("received.command.nrtrains", min_args=1)
def trains(self, event):
"""
@ -298,7 +297,6 @@ class Module(ModuleManager.BaseModule):
else:
event["stdout"].write("%s%s: %s" % (station_summary, " departures calling at %s" % filter["inter"] if filter["inter"] else '', trains_string))
@utils.hook("telegram.command.nrservice")
@utils.hook("received.command.nrservice", min_args=1)
def service(self, event):
"""
@ -494,7 +492,6 @@ class Module(ModuleManager.BaseModule):
len(stations_filtered), total_count,
", ".join([s["summary"] for s in stations_filtered])))
@utils.hook("telegram.command.nrhead")
@utils.hook("received.command.nrhead", min_args=1)
def head(self, event):
"""
@ -517,7 +514,6 @@ class Module(ModuleManager.BaseModule):
else:
event["stdout"].write(", ".join(["h/%s r/%s u/%s rs/%s %s (%s) -> %s (%s)" % (a["trainid"], a["rid"], a["uid"], a["rsid"], a["originName"], a["originCrs"], a["destinationName"], a["destinationCrs"]) for a in services]))
@utils.hook("telegram.command.nrcode")
@utils.hook("received.command.nrcode", min_args=1)
def service_code(self, event):
"""

View file

@ -1,62 +0,0 @@
#--ignore
import telegram, telegram.ext
from src import utils
import json
from datetime import datetime
from threading import Thread
class Module(Thread):
_name = "telegram"
def on_load(self):
key = self.bot.config.get("telegram-api-key")
if not key: return
self.updater = telegram.ext.Updater(key)
self.dispatcher = self.updater.dispatcher
start_handler = telegram.ext.CommandHandler("start", self.start)
command_handler = telegram.ext.MessageHandler(
telegram.ext.Filters.command, self.handle)
self.dispatcher.add_handler(start_handler)
self.dispatcher.add_handler(command_handler)
self.updater.start_polling()
def start(self, bot, update):
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
text = text.replace("\r", '').replace("\n", " ")
command = text.split(" ")[0][1:]
command = command.split("@")[0]
args = text.split(" ", 1)[1:][0] if " " in text else ""
data = {
"chat_id": message.chat_id,
"message_id": message.message_id,
"line": text,
"command": command,
"args": args,
"args_split": text.split(" ")[1:],
"stdout": IOWrapper(bot, message.chat_id, message.message_id),
"stderr": IOWrapper(bot, message.chat_id, message.message_id),
"external": True,
}
self.events.on("telegram.command").on(command).call(**data)
@utils.hook("signal.interrupt")
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:
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")

View file

@ -1,6 +1,5 @@
beautifulsoup4
Flask
python-telegram-bot
requests
scrypt
suds-jurko