Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/weekly_rss/__init__.py
2021-08-26 01:09:17 +08:00

30 lines
1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import asyncio
import traceback
from apscheduler.triggers.cron import CronTrigger
from core.loader.decorator import command
from core.logger import Logger
from core.scheduler import Scheduler
from database import BotDBUtil
from modules.weekly import get_weekly
@command('weekly_rss', autorun=True, help_doc=('{订阅中文 Minecraft Wiki 的每周页面(每周一 830 更新)。}'))
async def weekly_rss(bot):
@Scheduler.scheduled_job(CronTrigger.from_crontab('30 8 * * MON'))
async def check_weekly():
Logger.info('Checking MCWZH weekly...')
weekly = await get_weekly()
get_target_id = BotDBUtil.Module.get_enabled_this('weekly_rss')
for x in get_target_id:
fetch = await bot.fetch_target(x)
if fetch:
try:
await fetch.sendMessage(weekly[0], weekly[1])
await asyncio.sleep(0.5)
except Exception:
traceback.print_exc()
Logger.info(weekly[0])
Logger.info('Weekly checked.')