File tree Expand file tree Collapse file tree 4 files changed +31
-24
lines changed Expand file tree Collapse file tree 4 files changed +31
-24
lines changed Original file line number Diff line number Diff line change 11web : gunicorn system.wsgi:app
2- webhook : flask webhook
2+ webhook : flask telegram webhook
33upgrade : flask db upgrade
Original file line number Diff line number Diff line change 1- import click
2-
3- from flask .cli import with_appcontext
4-
5- import telegram_bot .polling
6- import telegram_bot .webhook
7-
8-
9- @click .command ('polling' )
10- @with_appcontext
11- def start_polling ():
12- telegram_bot .polling .start_polling ()
13-
14-
15- @click .command ('webhook' )
16- @with_appcontext
17- def start_webhook ():
18- telegram_bot .webhook .set_webhook ()
1+ from telegram_bot .commands import telegram_cli
192
203
214def register_commands (app ):
22- app .cli .add_command (start_polling )
23- app .cli .add_command (start_webhook )
5+ app .cli .add_command (telegram_cli )
Original file line number Diff line number Diff line change 1+ from flask .cli import AppGroup , with_appcontext
2+
3+ import telegram_bot .polling
4+ import telegram_bot .webhook
5+
6+
7+ telegram_cli = AppGroup ('telegram' )
8+
9+
10+ @telegram_cli .command ('polling' )
11+ @with_appcontext
12+ def start_polling ():
13+ """
14+ Starts telegram bot in the long-polling mode
15+ """
16+ telegram_bot .polling .start_polling ()
17+
18+
19+ @telegram_cli .command ('webhook' )
20+ @with_appcontext
21+ def start_webhook ():
22+ """
23+ Starts telegram bot in the webhook mode
24+ """
25+ telegram_bot .webhook .set_webhook ()
Original file line number Diff line number Diff line change 44
55
66def set_webhook ():
7- host_url = current_app .config [ 'HOST_URL' ]
8- host_port = current_app .config [ 'HOST_PORT' ]
9- telegram_token = current_app .config [ 'TELEGRAM_TOKEN' ]
7+ host_url = current_app .config . get ( 'HOST_URL' )
8+ host_port = current_app .config . get ( 'HOST_PORT' )
9+ telegram_token = current_app .config . get ( 'TELEGRAM_TOKEN' )
1010 bot = TelegramBot (telegram_token )
1111 bot .set_webhook (
1212 webhook_url = 'https://%s:%s/telegram/%s' % (
You can’t perform that action at this time.
0 commit comments