async def on_ready(): global roles roles = Roles() roles.setup_definitions(bot) login() bot.loop.create_task(refresh()) bot.loop.create_task(load_listener()) bot.add_cog(AdminFunctions()) bot.add_cog(NewUserFunctions()) bot.add_cog(UserFunctions()) bot.add_cog(RoleSub()) bot.add_cog(Diplomat()) await scheule_builder()
from apscheduler.schedulers.asyncio import AsyncIOScheduler import atexit import requests from json import JSONDecodeError from tzlocal import get_localzone import datetime import os, time from definitions import Roles roles = Roles() scheduler = AsyncIOScheduler() n_time_h = int(os.getenv("EVENT_NOTIFICATION_TIME_HOUR")) n_time_m = int(os.getenv("EVENT_NOTIFICATION_TIME_MIN")) offset = int(os.getenv("TZ_OFFSET")) async def scheule_builder(): time.tzset() roles.log.warning('starting scheduler') roles.log.warning(get_localzone()) roles.log.warning(datetime.datetime.now()) scheduler.add_job(func=get_events, trigger="cron", hour=n_time_h, minute=n_time_m) scheduler.start() roles.log.warning('job added') atexit.register(lambda: scheduler.shutdown()) async def get_events(): try: roles.log.warning('looking for events') headers = {'Authorization': roles.auth_token, 'Content-Type': 'application/json'}