-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
43 lines (31 loc) · 1.21 KB
/
app.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
40
41
42
43
import logging
from handlers.common_handlers import start
from handlers.coffee_handler import coffee, stop_poll, poll_answer_handler
from handlers.config_handler import get_token
from telegram import Update
from telegram.ext import (
Application,
CommandHandler,
CallbackQueryHandler,
PollAnswerHandler
)
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO
)
# set higher logging level for httpx to avoid all GET and POST requests being logged
logging.getLogger("httpx").setLevel(logging.WARNING)
logger = logging.getLogger(__name__)
TOKEN = get_token()
def main() -> None:
"""Run the bot."""
# Create the Application and pass it bot's token.
application = Application.builder().token(TOKEN).build()
application.add_handler(CommandHandler("start", start))
application.add_handler(CommandHandler("coffee", coffee))
application.add_handler(CallbackQueryHandler(stop_poll, pattern='^stop_poll$'))
application.add_handler(PollAnswerHandler(poll_answer_handler))
# Run the bot until the user presses Ctrl-C
application.run_polling(allowed_updates=Update.ALL_TYPES)
if __name__ == "__main__":
main()