diff options
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 11 |
1 files changed, 6 insertions, 5 deletions
| @@ -1,13 +1,12 @@ | |||
| 1 | import optparse | 1 | import optparse |
| 2 | 2 | ||
| 3 | from aiogram import executor, types as t, Dispatcher | 3 | from aiogram import executor, types as t, Dispatcher |
| 4 | from shared.instances import dp, bot | ||
| 5 | import logging | 4 | import logging |
| 6 | from shared import config | 5 | from shared import config |
| 7 | 6 | ||
| 8 | logging.basicConfig(level=logging.INFO) | 7 | logging.basicConfig(level=logging.INFO) |
| 9 | 8 | ||
| 10 | parser = optparse.OptionParser(conflict_handler="resolve") | 9 | parser = optparse.OptionParser(conflict_handler="resolve") # Делает прикол с аргументами |
| 11 | parser.add_option('-t', '--test', | 10 | parser.add_option('-t', '--test', |
| 12 | action="store_true", | 11 | action="store_true", |
| 13 | dest='test', | 12 | dest='test', |
| @@ -16,7 +15,7 @@ parser.add_option('-m', '--main', | |||
| 16 | action="store_true", | 15 | action="store_true", |
| 17 | dest='main', | 16 | dest='main', |
| 18 | help='main token') | 17 | help='main token') |
| 19 | values, args = parser.parse_args() | 18 | values, args = parser.parse_args() # Либа хуйня |
| 20 | 19 | ||
| 21 | if values.test: | 20 | if values.test: |
| 22 | config.token = config.test_token | 21 | config.token = config.test_token |
| @@ -29,12 +28,14 @@ else: | |||
| 29 | async def on_start(dp: Dispatcher): | 28 | async def on_start(dp: Dispatcher): |
| 30 | from shared.commands import commands | 29 | from shared.commands import commands |
| 31 | for scope, cmd in commands.items(): | 30 | for scope, cmd in commands.items(): |
| 32 | await bot.set_my_commands(cmd, scope) | 31 | await dp.bot.delete_my_commands(scope) |
| 32 | await dp.bot.set_my_commands(cmd, scope) | ||
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | if __name__ == '__main__': | 35 | if __name__ == '__main__': |
| 36 | from shared.instances import dp | ||
| 36 | import handlers | 37 | import handlers |
| 37 | 38 | ||
| 38 | executor.start_polling( | 39 | executor.start_polling( |
| 39 | dp, allowed_updates=t.AllowedUpdates.all(), on_startup=on_start | 40 | dp, allowed_updates=t.AllowedUpdates.all(), on_startup=on_start, skip_updates=True |
| 40 | ) | 41 | ) |
