44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
|
import logging
|
||
|
|
||
|
from aiogram import executor
|
||
|
|
||
|
from load import dp, config
|
||
|
import filters
|
||
|
import handlers
|
||
|
|
||
|
skip_updates=True
|
||
|
|
||
|
|
||
|
logging.basicConfig(
|
||
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||
|
level=logging.INFO
|
||
|
)
|
||
|
|
||
|
async def on_startup(dp):
|
||
|
webhook_url = "{host}{path}{token}".format(
|
||
|
host=config["WebHook"]["webhook_host"],
|
||
|
path=config["WebHook"]["webhook_path"],
|
||
|
token=config["Bot"]["token"]
|
||
|
)
|
||
|
await dp.bot.set_webhook(url=webhook_url)
|
||
|
|
||
|
|
||
|
async def on_shutdown(dp):
|
||
|
await dp.bot.delete_webhook()
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
|
||
|
if config["WebHook"]["use"].lower() in ["yes", "true"]:
|
||
|
executor.start_webhook(
|
||
|
dispatcher=dp,
|
||
|
skip_updates=skip_updates,
|
||
|
webhook_path="{}{}".format(config["WebHook"]["webhook_path"], config["Bot"]["token"]),
|
||
|
on_startup=on_startup,
|
||
|
on_shutdown=on_shutdown,
|
||
|
host=config["WebHook"]["app_host"],
|
||
|
port=config["WebHook"]["app_port"]
|
||
|
)
|
||
|
else:
|
||
|
executor.start_polling(dp, skip_updates=skip_updates)
|