-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
39 lines (28 loc) · 913 Bytes
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import logging
import os
from dotenv import load_dotenv
from telegram.ext import Updater, CallbackContext
from telegram import Update
from app.handlers.commons import init_handlers
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=logging.INFO
)
def start(update: Update, context: CallbackContext):
context.bot.send_message(
chat_id=update.effective_chat.id, text="I'm a bot, please talk to me!"
)
def default(update: Update, context: CallbackContext):
context.bot.send_message(
chat_id=update.effective_chat.id,
text="Sorry, I didn't understand that command.",
)
if __name__ == "__main__":
load_dotenv()
# Updater
updater = Updater(token=os.getenv("TOKEN"), use_context=True)
dispatcher = updater.dispatcher
# Handlers
init_handlers(dispatcher)
# Strat bot
updater.start_polling()