diff options
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 23 |
1 files changed, 23 insertions, 0 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 | ) |
