36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
import os
|
|
|
|
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
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
API_TOKEN = os.getenv('API_TOKEN')
|
|
|
|
|
|
# Создаем объект бота и диспетчера
|
|
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())
|