nonebot2/docs/guide/code/awesome-bot-6/awesome/plugins/scheduler.py
2018-12-27 20:23:45 +08:00

17 lines
436 B
Python

from datetime import datetime
import nonebot
import pytz
from aiocqhttp.exceptions import Error as CQHttpError
@nonebot.scheduler.scheduled_job('cron', hour='*')
async def _():
bot = nonebot.get_bot()
now = datetime.now(pytz.timezone('Asia/Shanghai'))
try:
await bot.send_group_msg(group_id=672076603,
message=f'现在{now.hour}点整啦!')
except CQHttpError:
pass