From 381d93a9db34cf84591a1c0ad0ddd3f82f07373a Mon Sep 17 00:00:00 2001 From: nicklly <1134741727@qq.com> Date: Sun, 28 Aug 2022 17:20:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/Genshin_Calendar/__init__.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/LittlePaimon/plugins/Genshin_Calendar/__init__.py b/LittlePaimon/plugins/Genshin_Calendar/__init__.py index 298945f..4121fe2 100644 --- a/LittlePaimon/plugins/Genshin_Calendar/__init__.py +++ b/LittlePaimon/plugins/Genshin_Calendar/__init__.py @@ -1,5 +1,8 @@ +from typing import Union + from nonebot import get_bot, on_command -from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment +from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment, GROUP_ADMIN +from nonebot.permission import SUPERUSER from nonebot.plugin import PluginMetadata from .generate import * @@ -16,14 +19,14 @@ __plugin_meta__ = PluginMetadata( "原神日历 on 时间/off : 订阅/取消订阅指定服务器的日历推送\n" ), extra={ - 'type': '原神Wiki', - "author": "nicklly <1134741727@qq.com>", + 'type': '原神Wiki', + "author": "nicklly <1134741727@qq.com>", "version": "1.0.1", 'priority': 7, }, ) -calendar = on_command('原神日历', aliases={'原神日程', '活动日历'}, priority=10, block=True) +calendar = on_command('原神日历', aliases={'原神日程', '活动日历'}, permission=SUPERUSER | GROUP_ADMIN, priority=10, block=True) @calendar.handle() @@ -38,13 +41,18 @@ async def _(event: MessageEvent, sub_id=CommandObjectID(), switch=CommandSwitch( sub_data['extra_id'] = event.guild_id if switch: if sub_time: - await GeneralSub.update_or_create(**sub_data, defaults={'sub_hour': sub_time[0], 'sub_minute': sub_time[1]}) + await GeneralSub.update_or_create(**sub_data, + defaults={'sub_hour': sub_time[0], 'sub_minute': sub_time[1]}) if scheduler.get_job(f'genshin_calendar_{sub_id}'): scheduler.remove_job(f'genshin_calendar_{sub_id}') - scheduler.add_job(func=send_calendar, trigger='cron', hour=sub_time[0], minute=sub_time[1], id=f'genshin_calendar_{sub_id}', args=(sub_data['sub_id'], sub_data['sub_type'], sub_data.get('extra_id', None)), misfire_grace_time=10) + scheduler.add_job(func=send_calendar, trigger='cron', hour=sub_time[0], minute=sub_time[1], + id=f'genshin_calendar_{sub_id}', + args=(sub_data['sub_id'], sub_data['sub_type'], sub_data.get('extra_id', None)), + misfire_grace_time=10) - logger.info('原神日历', '', {sub_data['sub_type']: sub_id, 'time': f'{sub_time[0]}:{sub_time[1]}'}, '订阅成功', True) + logger.info('原神日历', '', {sub_data['sub_type']: sub_id, 'time': f'{sub_time[0]}:{sub_time[1]}'}, '订阅成功', + True) await calendar.finish(f'原神日历订阅成功, 将在每日{sub_time[0]}:{sub_time[1]}推送') else: From 41763e3e0c9af07caa9d05110ade89463c12f23c Mon Sep 17 00:00:00 2001 From: nicklly <1134741727@qq.com> Date: Sun, 28 Aug 2022 17:22:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E9=83=A8=E5=88=86ann=5Fi?= =?UTF-8?q?ds=E5=8F=8A=E9=83=A8=E5=88=86=E5=85=B3=E9=94=AE=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LittlePaimon/plugins/Genshin_Calendar/event.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/LittlePaimon/plugins/Genshin_Calendar/event.py b/LittlePaimon/plugins/Genshin_Calendar/event.py index 7ffb187..abfe286 100644 --- a/LittlePaimon/plugins/Genshin_Calendar/event.py +++ b/LittlePaimon/plugins/Genshin_Calendar/event.py @@ -30,17 +30,18 @@ ignored_key_words = [ "防沉迷", "问卷", "公平运营", - "纪行", "有奖活动", "反馈功能" ] ignored_ann_ids = [ - 495, # 有奖问卷调查开启! - 1263, # 米游社《原神》专属工具一览 423, # 《原神》玩家社区一览 - 422, # 《原神》防沉迷系统说明 + 495, # 有奖问卷调查开启! 762, # 《原神》公平运营声明 + 1263, # 米游社《原神》专属工具一览 + 2388, # 原神问卷调查 + 2522, # 《原神》防沉迷系统说明 + 2911, # 功能反馈 ] list_api = 'https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnList?game=hk4e&game_biz=hk4e_cn&lang=zh-cn&bundle_id=hk4e_cn&platform=pc®ion=cn_gf01&level=55&uid=100000000'