tg_rss_bot/telegram/command_processor.py
Alexey Skobkin 6c83447eb8
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
telegram. Code style changes.
2022-05-02 23:44:16 +03:00

35 lines
1.3 KiB
Python

import telebot
from telebot.types import Message
class CommandProcessor:
"""Processes user input and dispatches the data to other services."""
bot: telebot.TeleBot
def __init__(self, token: str):
if token is None or len(token) == 0:
raise ValueError("Token should not be empty")
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):
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)')