misskey2telegram/modules/announcement.py

16 lines
480 B
Python
Raw Normal View History

2023-01-27 12:36:41 +00:00
from models.services.scheduler import scheduler
2023-01-24 07:23:25 +00:00
from defs.announcement import get_unread_announcements
2023-01-27 12:36:41 +00:00
from misskey_init import misskey_bot_map
2023-01-24 07:23:25 +00:00
@scheduler.scheduled_job("interval", minutes=15, id="check_announcement")
async def announcement():
2023-01-27 12:36:41 +00:00
for bot in misskey_bot_map.values():
data = await get_unread_announcements(bot)
for an in data:
try:
await an.send_notice()
finally:
await an.mark_as_read()