diff options
| author | Igor <50257429+igorechek06@users.noreply.github.com> | 2021-08-28 21:14:07 +0900 |
|---|---|---|
| committer | Igor <50257429+igorechek06@users.noreply.github.com> | 2021-08-28 21:14:07 +0900 |
| commit | 47df0f93f2c4e91246f2a7ef36086dd159c24adf (patch) | |
| tree | 4184471662acef0023d936fb1155e3c4ddbc49b9 | |
| parent | a8582c60e3bed5b93c989e2963d40130771cf11d (diff) | |
| download | karpov_ai_bot-47df0f93f2c4e91246f2a7ef36086dd159c24adf.tar.gz karpov_ai_bot-47df0f93f2c4e91246f2a7ef36086dd159c24adf.zip | |
0.0.1
| -rw-r--r-- | main.py | 23 | ||||
| -rw-r--r-- | shared/instances.py | 4 |
2 files changed, 25 insertions, 2 deletions
| @@ -1,17 +1,40 @@ | |||
| 1 | import optparse | ||
| 2 | |||
| 1 | from aiogram import executor, types as t, Dispatcher | 3 | from aiogram import executor, types as t, Dispatcher |
| 2 | from shared.instances import dp, bot | 4 | from shared.instances import dp, bot |
| 3 | import logging | 5 | import logging |
| 6 | from shared import config | ||
| 4 | 7 | ||
| 5 | logging.basicConfig(level=logging.INFO) | 8 | logging.basicConfig(level=logging.INFO) |
| 6 | 9 | ||
| 10 | parser = optparse.OptionParser(conflict_handler="resolve") | ||
| 11 | parser.add_option('-t', '--test', | ||
| 12 | action="store_true", | ||
| 13 | dest='test', | ||
| 14 | help='test token') | ||
| 15 | parser.add_option('-m', '--main', | ||
| 16 | action="store_true", | ||
| 17 | dest='main', | ||
| 18 | help='main token') | ||
| 19 | values, args = parser.parse_args() | ||
| 20 | |||
| 21 | if values.test: | ||
| 22 | config.token = config.test_token | ||
| 23 | elif values.main: | ||
| 24 | config.token = config.main_token | ||
| 25 | else: | ||
| 26 | config.token = config.test_token | ||
| 27 | |||
| 7 | 28 | ||
| 8 | async def on_start(dp: Dispatcher): | 29 | async def on_start(dp: Dispatcher): |
| 9 | from shared.commands import commands | 30 | from shared.commands import commands |
| 10 | for scope, cmd in commands.items(): | 31 | for scope, cmd in commands.items(): |
| 11 | await bot.set_my_commands(cmd, scope) | 32 | await bot.set_my_commands(cmd, scope) |
| 12 | 33 | ||
| 34 | |||
| 13 | if __name__ == '__main__': | 35 | if __name__ == '__main__': |
| 14 | import handlers | 36 | import handlers |
| 37 | |||
| 15 | executor.start_polling( | 38 | executor.start_polling( |
| 16 | dp, allowed_updates=t.AllowedUpdates.all(), on_startup=on_start | 39 | dp, allowed_updates=t.AllowedUpdates.all(), on_startup=on_start |
| 17 | ) | 40 | ) |
diff --git a/shared/instances.py b/shared/instances.py index 7eb883c..0a6153d 100644 --- a/shared/instances.py +++ b/shared/instances.py | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | from aiogram import Bot, Dispatcher | 1 | from aiogram import Bot, Dispatcher |
| 2 | from .config import TOKEN | 2 | from .config import token |
| 3 | 3 | ||
| 4 | bot = Bot(token=TOKEN) | 4 | bot = Bot(token=token) |
| 5 | dp = Dispatcher(bot) | 5 | dp = Dispatcher(bot) |
