fix scheduler

This commit is contained in:
Dmitry Afanasyev 2023-04-18 20:16:52 +03:00
parent 585367e621
commit d88ef52c53
4 changed files with 4 additions and 4 deletions

View File

@ -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"

View File

@ -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..')

View File

@ -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)

View File

@ -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()