31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
|
from aiogram import Bot, Dispatcher
|
||
|
import asyncio
|
||
|
import bot
|
||
|
from utils import get_usd_rub_course, checking_and_deleting_users
|
||
|
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||
|
|
||
|
API_TOKEN = "6594413238:AAFahDg955k1GE9a4JE9T9yHyQoJZV5TFEk"
|
||
|
|
||
|
|
||
|
# Создаем объект бота и диспетчера
|
||
|
bot_chat = Bot(token=API_TOKEN)
|
||
|
dp = Dispatcher()
|
||
|
|
||
|
|
||
|
async def main() -> None:
|
||
|
""" Запуск бота """
|
||
|
dp.include_router(bot.router)
|
||
|
scheduler = AsyncIOScheduler()
|
||
|
# Планируем выполнение функции в 12:00, 18:00 и 00:00 планировщиком
|
||
|
scheduler.add_job(get_usd_rub_course, 'cron', hour='12,18,0')
|
||
|
# Планируем выполнение функции checking_and_deleting_users ежедневно в 00:12
|
||
|
scheduler.add_job(checking_and_deleting_users, 'cron', hour=0, minute=12)
|
||
|
scheduler.start()
|
||
|
await dp.start_polling(bot_chat)
|
||
|
while True:
|
||
|
await asyncio.sleep(1)
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
asyncio.run(main())
|