From e8cb2fd3c572570991ce434dfff10ed3e5a69c07 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Mon, 2 May 2022 02:43:04 +0300 Subject: [PATCH] Telegram package draft. --- telegram/__init__.py | 0 telegram/command_processor.py | 25 +++++++++++++++++++++++++ telegram/notifier.py | 11 +++++++++++ 3 files changed, 36 insertions(+) create mode 100644 telegram/__init__.py create mode 100644 telegram/command_processor.py create mode 100644 telegram/notifier.py diff --git a/telegram/__init__.py b/telegram/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/telegram/command_processor.py b/telegram/command_processor.py new file mode 100644 index 0000000..bd5f162 --- /dev/null +++ b/telegram/command_processor.py @@ -0,0 +1,25 @@ +import telebot +from telebot.types import Message + + +class CommandProcessor: + bot: telebot.TeleBot + + def __init__(self, token: str): + self.bot = telebot.TeleBot(token) + + def run(self): + self.bot.register_message_handler(commands=['help', 'start'], callback=self.__command_help) + self.bot.infinity_polling() + + def __command_help(self, message: Message): + self.bot.reply_to(message, 'Commands: "/add", "/list", "/del", "/help".') + + def __add_feed(self, message: Message): + self.bot.reply_to(message, 'Feed added (stub)') + + def __list_feeds(self, message: Message): + self.bot.reply_to(message, 'Your feeds: (stub)') + + def __delete_feed(self, message: Message): + self.bot.reply_to(message, 'Feed deleted: (stub)') diff --git a/telegram/notifier.py b/telegram/notifier.py new file mode 100644 index 0000000..1eb2b85 --- /dev/null +++ b/telegram/notifier.py @@ -0,0 +1,11 @@ +import telebot + + +class Notifier: + bot: telebot.TeleBot + + def __init__(self, token: str): + self.bot = telebot.TeleBot(token) + + def notify(self, chat_id: int): + self.bot.send_message(chat_id=chat_id, text="Notification stub")