This commit is contained in:
yasir 2023-02-27 11:48:44 +07:00
parent 204527e5f1
commit 6fba574298
2 changed files with 9 additions and 8 deletions

View file

@ -5,7 +5,6 @@ from logging import ERROR, INFO, FileHandler, StreamHandler, basicConfig, getLog
import pyromod.listen import pyromod.listen
from apscheduler.jobstores.mongodb import MongoDBJobStore from apscheduler.jobstores.mongodb import MongoDBJobStore
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from pymongo import MongoClient from pymongo import MongoClient
from pyrogram import Client from pyrogram import Client
@ -47,13 +46,6 @@ jobstores = {
database="MissKatyDB", database="MissKatyDB",
collection='nightmode')} collection='nightmode')}
scheduler = AsyncIOScheduler(
jobstores=jobstores,
timezone=TZ)
logging.info(scheduler.get_jobs())
if bool(scheduler.get_jobs()):
scheduler.start()
app.start() app.start()
user.start() user.start()
bot = app.get_me() bot = app.get_me()

View file

@ -18,12 +18,15 @@ from pyrogram.raw.all import layer
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from database.users_chats_db import db from database.users_chats_db import db
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from misskaty import ( from misskaty import (
BOT_NAME, BOT_NAME,
BOT_USERNAME, BOT_USERNAME,
HELPABLE, HELPABLE,
UBOT_NAME, UBOT_NAME,
TZ,
app, app,
jobstores
) )
from misskaty.core.message_utils import * from misskaty.core.message_utils import *
from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.core.decorator.ratelimiter import ratelimiter
@ -70,6 +73,12 @@ async def start_bot():
) )
except Exception as e: except Exception as e:
LOGGER.error(str(e)) LOGGER.error(str(e))
scheduler = AsyncIOScheduler(
jobstores=jobstores,
timezone=TZ)
LOGGER.info(scheduler.get_jobs())
if bool(scheduler.get_jobs()):
scheduler.start()
if os.path.exists("restart.pickle"): if os.path.exists("restart.pickle"):
with open('restart.pickle', 'rb') as status: with open('restart.pickle', 'rb') as status:
chat_id, message_id = pickle.load(status) chat_id, message_id = pickle.load(status)