ShopBot/bot.py

44 lines
910 B
Python
Raw Permalink Normal View History

2022-06-04 22:02:51 +03:00
#!/usr/bin/env python
import logging
from aiogram import executor
from load import dp, bot
import config
import filters
import handlers
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
)
logger = logging.getLogger(__name__)
async def on_startup(dp):
await bot.set_webhook(url=config.webhook_url)
async def on_shutdown(dp):
await bot.delete_webhook()
def main() -> None:
if config.use_webhook:
executor.start_webhook(
dispatcher=dp,
webhook_path=config.webhook_path,
on_startup=on_startup,
on_shutdown=on_shutdown,
skip_updates=config.skip_updates,
host=config.webhook_app_host,
port=config.webhook_app_port,
)
else:
executor.start_polling(dp, skip_updates=config.skip_updates)
if __name__ == '__main__':
main()