2024-08-16 05:42:00 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
from aiogram import Bot, Dispatcher
|
|
|
|
import asyncio
|
|
|
|
import bot
|
2024-08-16 15:25:29 +00:00
|
|
|
from utils import get_usd_rub_course, checking_and_deleting_users, check_table_exists_users, check_table_exists_usd_rub, \
|
|
|
|
check_table_exists_successful_hash
|
2024-08-16 05:42:00 +00:00
|
|
|
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()
|
2024-08-16 15:25:29 +00:00
|
|
|
check_table_exists_users()
|
|
|
|
check_table_exists_usd_rub()
|
|
|
|
check_table_exists_successful_hash()
|
|
|
|
await get_usd_rub_course()
|
2024-08-16 05:42:00 +00:00
|
|
|
# Планируем выполнение функции в 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())
|