1 | # This file is part of python-cinema-club-bot
|
---|
2 | # contributed in 2024 by Mikhail Kirillov (~w96k) <w96k@runbox.com>
|
---|
3 |
|
---|
4 | # To the extent possible under law, the author(s) have dedicated all copyright
|
---|
5 | # and related and neighboring rights to this software to the public domain
|
---|
6 | # worldwide. This software is distributed without any warranty.
|
---|
7 |
|
---|
8 | # You should have received a copy of the CC0 Public Domain Dedication along
|
---|
9 | # with this software. If not, see:
|
---|
10 | # <http://creativecommons.org/publicdomain/zero/1.0/>
|
---|
11 |
|
---|
12 | from telegram import Update
|
---|
13 | from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes, \
|
---|
14 | MessageHandler, filters
|
---|
15 | from dotenv import load_dotenv
|
---|
16 | import os
|
---|
17 | import logging
|
---|
18 |
|
---|
19 | from strings import INVALID_COMMAND
|
---|
20 | from persistence import Persistence
|
---|
21 | import commands
|
---|
22 |
|
---|
23 |
|
---|
24 | load_dotenv()
|
---|
25 |
|
---|
26 | logging.basicConfig(
|
---|
27 | level=logging.INFO,
|
---|
28 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
---|
29 | )
|
---|
30 |
|
---|
31 |
|
---|
32 | async def unknown(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
---|
33 | await context.bot.send_message(
|
---|
34 | chat_id=update.effective_chat.id,
|
---|
35 | text=INVALID_COMMAND
|
---|
36 | )
|
---|
37 |
|
---|
38 |
|
---|
39 | if __name__ == "__main__":
|
---|
40 | app = ApplicationBuilder().token(
|
---|
41 | os.environ.get("TELEGRAM_TOKEN")
|
---|
42 | ).persistence(Persistence).build()
|
---|
43 |
|
---|
44 | app.add_handler(CommandHandler("about", commands.about))
|
---|
45 | app.add_handler(CommandHandler("add", commands.add_users))
|
---|
46 | app.add_handler(CommandHandler("list", commands.list_users))
|
---|
47 | app.add_handler(CommandHandler("remove", commands.remove_users))
|
---|
48 | app.add_handler(CommandHandler("chooser", commands.chooser_user))
|
---|
49 |
|
---|
50 |
|
---|
51 | app.add_handler(MessageHandler(filters.COMMAND, unknown))
|
---|
52 |
|
---|
53 | app.run_polling()
|
---|