nonebot2/docs/guide/code/awesome-bot-6/awesome/plugins/scheduler.py

17 lines
436 B
Python
Raw Normal View History

2018-08-26 12:35:53 +08:00
from datetime import datetime
2018-12-27 20:23:45 +08:00
import nonebot
2018-08-26 12:35:53 +08:00
import pytz
from aiocqhttp.exceptions import Error as CQHttpError
2018-12-27 20:23:45 +08:00
@nonebot.scheduler.scheduled_job('cron', hour='*')
2018-08-26 12:35:53 +08:00
async def _():
2018-12-27 20:23:45 +08:00
bot = nonebot.get_bot()
2018-08-26 12:35:53 +08:00
now = datetime.now(pytz.timezone('Asia/Shanghai'))
try:
await bot.send_group_msg(group_id=672076603,
message=f'现在{now.hour}点整啦!')
except CQHttpError:
pass