From db7369af638b835e3a5c44c35a3c33f5ef1380d5 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Mon, 2 May 2022 18:18:13 +0300 Subject: [PATCH] #7 Registering handlers in CommandProcessor. Some docstrings added. --- telegram/command_processor.py | 9 ++++++--- telegram/notifier.py | 5 ++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/telegram/command_processor.py b/telegram/command_processor.py index bc5d2d2..6129ded 100644 --- a/telegram/command_processor.py +++ b/telegram/command_processor.py @@ -3,9 +3,7 @@ from telebot.types import Message class CommandProcessor: - """ - Processes user input and dispatches the data to other services. - """ + """Processes user input and dispatches the data to other services.""" bot: telebot.TeleBot @@ -13,7 +11,12 @@ class CommandProcessor: self.bot = telebot.TeleBot(token) def run(self): + """Runs a bot and polls for new messages indefinitely.""" self.bot.register_message_handler(commands=['help', 'start'], callback=self.__command_help) + self.bot.register_message_handler(commands=['add'], callback=self.__add_feed) + self.bot.register_message_handler(commands=['list'], callback=self.__list_feeds) + self.bot.register_message_handler(commands=['del'], callback=self.__delete_feed) + self.bot.infinity_polling() def __command_help(self, message: Message): diff --git a/telegram/notifier.py b/telegram/notifier.py index 633f901..9abdc55 100644 --- a/telegram/notifier.py +++ b/telegram/notifier.py @@ -2,9 +2,7 @@ import telebot class Notifier: - """ - Sends notifications to users about new RSS feed items. - """ + """Sends notifications to users about new RSS feed items.""" bot: telebot.TeleBot @@ -12,4 +10,5 @@ class Notifier: self.bot = telebot.TeleBot(token) def notify(self, chat_id: int): + """Send notification to the user""" self.bot.send_message(chat_id=chat_id, text="Notification stub")