mirror of
https://github.com/Balshgit/mosgortrans.git
synced 2025-09-11 13:00:40 +03:00
fix scheduler
This commit is contained in:
parent
585367e621
commit
d88ef52c53
@ -11,7 +11,5 @@ WEBAPP_PORT="8080"
|
||||
# set to true to start with webhook. Else bot will start on polling method
|
||||
START_WITH_WEBHOOK="true"
|
||||
|
||||
GECKO_DRIVER_VERSION="0.32.0"
|
||||
|
||||
# chat ids for scheduler tasks
|
||||
CHAT_IDS="123456789,987654321"
|
@ -27,7 +27,7 @@ class Application:
|
||||
TELEGRAM_API_TOKEN, '{TELEGRAM_API_TOKEN}'
|
||||
)
|
||||
)
|
||||
bot_scheduler.start()
|
||||
self.scheduler.start()
|
||||
|
||||
async def _on_shutdown(self, dp: Dispatcher) -> None:
|
||||
logger.warning('Shutting down..')
|
||||
|
@ -47,12 +47,13 @@ bot_cron_jobs = {
|
||||
|
||||
|
||||
class BotScheduler:
|
||||
scheduler = AsyncIOScheduler()
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
cron_jobs: dict[str, dict[str, Any]],
|
||||
):
|
||||
self.cron_jobs = cron_jobs
|
||||
self.scheduler = AsyncIOScheduler()
|
||||
|
||||
def add_scheduler_jobs(self, jobs_name: str) -> None:
|
||||
cron_jobs = self.cron_jobs.get(jobs_name)
|
||||
|
@ -21,4 +21,5 @@ if __name__ == '__main__':
|
||||
if START_WITH_WEBHOOK:
|
||||
web.run_app(app=app, host=WEBAPP_HOST, port=WEBAPP_PORT)
|
||||
else:
|
||||
application.scheduler.start()
|
||||
application.bot_polling()
|
||||
|
Loading…
x
Reference in New Issue
Block a user