#7 Implementing Telegram bot run script.
This commit is contained in:
parent
8f359847bf
commit
5509053bb0
|
@ -29,3 +29,10 @@ pip freeze > requirements.txt
|
|||
|
||||
**Do not forget** to install the latest dependencies before adding new dependencies and rewriting
|
||||
the `requirements.txt` file. Otherwise old dependencies could be lost.
|
||||
|
||||
## Running the bot
|
||||
|
||||
```shell
|
||||
export TELEGRAM_TOKEN=xxx
|
||||
python bot.py
|
||||
```
|
||||
|
|
13
bot.py
Normal file
13
bot.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
import logging
|
||||
import os
|
||||
from telegram.command_processor import CommandProcessor
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
token = os.getenv('TELEGRAM_TOKEN')
|
||||
|
||||
bot = CommandProcessor(token)
|
||||
logging.info("Starting Telegram bot")
|
||||
bot.run()
|
|
@ -2,6 +2,7 @@ certifi==2021.10.8
|
|||
charset-normalizer==2.0.12
|
||||
idna==3.3
|
||||
pyTelegramBotAPI==4.5.0
|
||||
python-dotenv==0.20.0
|
||||
requests==2.27.1
|
||||
urllib3==1.26.9
|
||||
feedparser==6.0.2
|
|
@ -1,13 +1,14 @@
|
|||
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):
|
||||
|
|
Loading…
Reference in a new issue