diff --git a/README.md b/README.md index 5d61dad..13633c6 100644 --- a/README.md +++ b/README.md @@ -25,22 +25,6 @@ _✨ 基于NoneBot2实现的 监测QQ群事件 插件 ✨_ > > 群成员荣誉变更时,发送变更通知 -## 指令结构: - -``` -path = { - 'chuo': ['戳一戳'], - 'honor': ['群荣誉检测'], - 'files': ['群文件检测'], - 'del_user': ['群成员减少检测'], - 'add_user': ['群成员增加检测'], - 'admin': ['管理员变动检测'], - 'red_package': ['运气王检测'] -} -``` - - - ## 安装方式 ### nb-cli安装(推荐) @@ -79,39 +63,55 @@ pip install --upgrade nonebot-plugin-eventmonitor | :-----: | :--: | :-----: | :----------: | :----------------: | | chuo_cd | int | 0 | chuo_cd = 10 | 戳一戳的cd(选填) | +## 指令结构帮助: + +``` +usage = """ + 指令1:戳一戳(戳一戳bot获取文案) + 指令2:群荣誉监测(检测群聊中龙王,群聊之火,快乐源泉的获得并发送提示,当 bot获得群荣誉时有特殊消息) + 指令3:群文件检测(检测所有人发送群文件并发送提示) + 指令4:群成员减少检测(当有人退群时,发送退群消息;当主人/superuser退群有特殊回复) + 指令5:群成员增加检测(当有人入群时,发送入群欢迎,当bot首次入群会乞讨管理,当主人/superuser入群会有特殊回复) + 指令6:管理员变动检测(当新增管理员或取消管理员时发送消息提示,当bot自身被上/下管理时有特殊回复) + 指令7:运气王检测(检测抢红包检测后的运气王并发送提示消息) + """ +``` +

更新日志

-- v0.1.7 +- v0.1.8 - - 新增所有功能开关[#issue5](https://github.com/Reversedeer/nonebot_plugin_eventmonitor/issues/9) - - - 增加权限控制 - - 修复潜在的bug + - 🚨增加功能开关指令:event状态/event配置 + - 🐛修复群文件不能检测bug(少写一个字母qwq) + - 优化目录结构 -- v0.1.6 - - 修复bug +- v0.1.7 + - 🚨新增所有功能开关[#issue5](https://github.com/Reversedeer/nonebot_plugin_eventmonitor/issues/9) + - 🚨新增权限控制 + - 🐛修复潜在的bug +- v0.1.6 + - 🐛修复bug - v0.1.5 + - 🐛修复获取superusers数值bug - 优化配置文件 [#issue4](https://github.com/Reversedeer/nonebot_plugin_eventmonitor/issues/6) - 删除冗余代码 - - 修复获取superusers数值bug - - v0.1.3 - - 修复配置文件bug + - 🐛修复配置文件bug - v0.1.2 - - 增加了戳一戳的文案 + - 🚨增加戳一戳的文案 - - 修改一些bug + - 🐛修复bug - v0.1.1 - - 好像改了什么..忘了... + - 🐛修复bug - v0.1.0 + - 🚨新增戳一戳加了cd(本人觉得功能鸡肋) + - 🐛修复管理员变动时API报错问题[#issue1](https://github.com/Reversedeer/nonebot_plugin_eventmonitor/issues/1) - 抛弃原有的配置模式 - - 给戳一戳加了cd(本人觉得功能鸡肋) - - 修复管理员变动时API报错问题[#issue1](https://github.com/Reversedeer/nonebot_plugin_eventmonitor/issues/1) - v0.0.6 - - 修复了大量的bug + - 🐛修复了大量的bug
## 关于 ISSUE @@ -134,6 +134,7 @@ pip install --upgrade nonebot-plugin-eventmonitor ## 其他插件 +[舔狗日记](https://github.com/Reversedeer/nonebot_plugin_dog) + [使用API的chatGPTQQ聊天机器人](https://github.com/Reversedeer/nonebot_plugin_chatGPT_openai) -[舔狗日记](https://github.com/Reversedeer/nonebot_plugin_dog) diff --git a/nonebot_plugin_eventmonitor/__init__.py b/nonebot_plugin_eventmonitor/__init__.py index 443694a..a18d1ef 100644 --- a/nonebot_plugin_eventmonitor/__init__.py +++ b/nonebot_plugin_eventmonitor/__init__.py @@ -1,171 +1,29 @@ -import nonebot -from nonebot.rule import Rule -from nonebot.plugin import on_notice, on_command -from nonebot.permission import SUPERUSER -from nonebot.adapters.onebot.v11.permission import GROUP_OWNER, GROUP_ADMIN -from nonebot.adapters.onebot.v11 import ( - Bot, Event, Message, - PokeNotifyEvent, - HonorNotifyEvent, - GroupUploadNoticeEvent, - GroupDecreaseNoticeEvent, - GroupIncreaseNoticeEvent, - GroupAdminNoticeEvent, - LuckyKingNotifyEvent, - MessageSegment, - GroupMessageEvent -) +import contextlib -from .stamp import chuo_send_msg -from .honour import monitor_rongyu -from .admin import del_user_bye, add_user_wecome, admin_changer from .utils import * -# 获取戳一戳状态 -async def _is_poke(event: Event) -> bool: - return isinstance(event, PokeNotifyEvent) and event.is_tome() -# 获取群荣誉变更 -async def _is_rongyu(event: Event) -> bool: - return isinstance(event, HonorNotifyEvent) -# 获取文件上传 -async def _is_checker(event: Event) -> bool: - return isinstance(event, GroupUploadNoticeEvent) -# 群成员减少 -async def _is_del_user(event: Event) -> bool: - return isinstance(event, GroupDecreaseNoticeEvent) -# 群成员增加 -async def _is_add_user(event: Event) -> bool: - return isinstance(event, GroupIncreaseNoticeEvent) -# 管理员变动 -async def _is_admin_change(event: Event) -> bool: - return isinstance(event, GroupAdminNoticeEvent) -# 红包运气王 -async def _is_red_packet(event: Event) -> bool: - return isinstance(event, LuckyKingNotifyEvent) - -# 戳一戳 -chuo = on_notice(Rule(_is_poke), priority=50, block=True) -# 群荣誉 -qrongyu = on_notice(Rule(_is_rongyu), priority=50, block=True) -# 群文件 -files = on_notice(Rule(_is_checker), priority=50, block=True) -# 群员减少 -del_user = on_notice(Rule(_is_del_user), priority=50, block=True) -# 群员增加 -add_user = on_notice(Rule(_is_add_user), priority=50, block=True) -# 群管理 -group_admin = on_notice(Rule(_is_admin_change), priority=50, block=True) -# 红包 -red_packet = on_notice(Rule(_is_red_packet), priority=50, block=True) - -switch_command = on_command("开启", aliases={"关闭"}, permission=SUPERUSER | GROUP_ADMIN | GROUP_OWNER, - priority=1, block=True) +#初始化配置配置文件 @driver.on_bot_connect async def _(): await init(g_temp) await config_check() - - -@chuo.handle() -async def send_chuo(event: PokeNotifyEvent): - if not (await check_chuo(g_temp, str(event.group_id))): - await chuo.finish(notAllow, at_sender=True) - uid = event.get_user_id() # 获取用户id - try: - cd = event.time - chuo_CD_dir[uid] # 计算cd - except KeyError: - cd = chuo_cd + 1 # 没有记录则cd为cd_time+1 - if ( - cd > chuo_cd - or event.get_user_id() in nonebot.get_driver().config.superusers - ): # 记录cd - chuo_CD_dir.update({uid: event.time}) - rely_msg = await chuo_send_msg() - await chuo.finish(message=Message(rely_msg)) - -@qrongyu.handle() #群荣誉变化 -async def send_rongyu(event: HonorNotifyEvent, bot: Bot): - if not (await check_honor(g_temp, str(event.group_id))): - await qrongyu.finish(notAllow, at_sender=True) - bot_qq = int(bot.self_id) - rely_msg = await monitor_rongyu(event.honor_type, event.user_id, bot_qq) - await qrongyu.finish(message=Message(rely_msg)) - -@files.handle() #上传群文件 -async def handle_first_receive(event: GroupUploadNoticeEvent): - if not (await check_file(g_temp, str(event.group_id))): - await files.finish(notAllow, at_sender=True) - rely = MessageSegment.at(event.user_id) + '\n' + \ - MessageSegment.image(f'https://q4.qlogo.cn/headimg_dl?dst_uin={event.user_id}&spec=640') + \ - '\n 上传了新文件,感谢你一直为群里做贡献喵~' + MessageSegment.face(175) - await files.finish(message=rely) - -@del_user.handle() #退群事件 -async def user_bye(event: GroupDecreaseNoticeEvent): - if not (await check_del_user(g_temp, str(event.group_id))): - await del_user.finish(notAllow, at_sender=True) - rely_msg = await del_user_bye(event.time, event.user_id) - await del_user.finish(message=Message(rely_msg)) - - -@add_user.handle() #入群事件 -async def user_welcome(event: GroupIncreaseNoticeEvent, bot: Bot): - if not (await check_add_user(g_temp, str(event.group_id))): - await add_user.finish(notAllow, at_sender=True) - bot_qq = int(bot.self_id) - rely_msg = await add_user_wecome(event.time, event.user_id, bot_qq) - await add_user.finish(message=Message(rely_msg)) - - -@group_admin.handle() #管理员变动 -async def admin_chance(event: GroupAdminNoticeEvent, bot: Bot): - if not (await check_admin(g_temp, str(event.group_id))): - await group_admin.finish(notAllow, at_sender=True) - bot_qq = int(bot.self_id) - rely_msg = await admin_changer(event.sub_type, event.user_id, bot_qq) - await group_admin.finish(message=Message(rely_msg)) - -@red_packet.handle() #红包运气王 -async def hongbao(event: LuckyKingNotifyEvent): - if not (await check_red_package(g_temp, str(event.group_id))): - await red_packet.finish(notAllow, at_sender=True) - rely_msg = MessageSegment.at(event.user_id) + "\n" + "本次红包运气王为:" + MessageSegment.at(event.target_id) - await red_packet.finish(message=rely_msg) - - -def get_command_type(command: str) -> str: - """根据指令内容获取开关类型""" - return next( - ( - key - for key, keywords in path.items() - if any(keyword in command for keyword in keywords) - ), - "", - ) -@switch_command.handle() -async def switch(event: GroupMessageEvent): - # 获取开关指令的参数,即用户输入的指令内容 - command = str(event.get_message()).strip() - # 获取群组ID - gid = str(event.group_id) - # 判断指令是否包含"开启"或"关闭"关键字 - if "开启" in command or "开始" in command: - if key := get_command_type(command): - g_temp[gid][key] = True - write_group_data(g_temp) - name = get_function_name(key) - await switch_command.finish(f"{name}功能已开启喵") - elif "禁止" in command or "关闭" in command: - if key := get_command_type(command): - g_temp[gid][key] = False - write_group_data(g_temp) - name = get_function_name(key) - await switch_command.finish(f"{name}功能已禁用喵") -def get_function_name(key: str) -> str: - """根据关键词获取对应功能名称""" - return path[key][0] \ No newline at end of file +with contextlib.suppress(Exception): + from nonebot.plugin import PluginMetadata + + __plugin_meta__ = PluginMetadata( + name="eventmonitor", + description="监控群事件的插件,支持戳一戳,成员变动,群荣誉变化等提示的插件", + usage=utils.usage, + type="application", + homepage="https://github.com/Reversedeer/nonebot_plugin_eventmonitor", + supported_adapters={"onebot.v11"}, + extra={ + "author": "Reversedeer", + "version": "0.1.8", + "priority": 50, + }, + ) \ No newline at end of file diff --git a/nonebot_plugin_eventmonitor/admin.py b/nonebot_plugin_eventmonitor/admin.py index 7c925d8..16f0bca 100644 --- a/nonebot_plugin_eventmonitor/admin.py +++ b/nonebot_plugin_eventmonitor/admin.py @@ -4,41 +4,60 @@ async def admin_changer(sub_type, user_id, bot_qq) : admin_msg = "" - + + # 根据管理员变动类型选择不同的消息 if sub_type == "set": + # 如果用户ID等于机器人的QQ号,返回特定消息 admin_msg = ( "我也是管理啦,你们要小心喵~" if user_id == bot_qq - else f"🚔 管理员变动\n恭喜[CQ:at,qq={user_id}]喜提本群管理喵~" + else f"🚔 管理员变动\n恭喜@{user_id}喜提本群管理喵~" ) elif sub_type == "unset": + # 如果用户ID等于机器人的QQ号,返回特定消息 admin_msg = ( "呜呜,别下咱管理呀QwQ,喵呜~" if user_id == bot_qq - else f"🚔 管理员变动\n[CQ:at,qq={user_id}]痛失本群管理喵~" + else f"🚔 管理员变动\n@{user_id}痛失本群管理喵~" ) + return admin_msg + async def del_user_bye(add_time, user_id): global del_user_msg del_time = datetime.fromtimestamp(add_time) + + # 检查用户ID是否在超级用户列表superusers中 if user_id in superusers: + # 如果是超级用户,生成特定的离开消息 del_user_msg = f"⌈{del_time}⌋\n@{user_id}恭送主人离开喵~" print(superusers) else: - del_user_msg = f"✈️ 成员变动⌈{del_time}⌋\nQQ号为:{user_id}的小可爱退群喵~" \ + # 如果不是超级用户,生成通用的离开消息,包含用户的QQ号和头像图片 + del_user_msg = f"✈️ 成员变动 ✈️ \n时间: ⌈{del_time}⌋\nQQ号为:{user_id}的小可爱退群喵~" \ f"[CQ:image,file=https://q4.qlogo.cn/headimg_dl?dst_uin={user_id}&spec=640]" + return del_user_msg + async def add_user_wecome(add_time, user_id, bot_qq): - global groups_all, add_user_msg - add_time = datetime.fromtimestamp(add_time) + global groups_all, add_user_msg + # 将时间戳转换为datetime类型的时间add_time + add_time = datetime.fromtimestamp(add_time) + # 判断用户ID是否等于机器人的QQ号 if user_id == bot_qq: + # 如果是机器人自己加入群组,生成特定的欢迎消息 add_user_msg = f"本喵被邀进入贵群喵~\n" \ f"火速上个管理喵~" + # 判断用户ID是否在超级用户列表superusers中 elif user_id in superusers: - add_user_msg = f"✨ 成员变动 ✨\n@{user_id}[CQ:at,qq={user_id}]欢迎主人进群喵~[CQ:face,id=175]" + # 如果是超级用户加入群组,生成特定的欢迎消息,包含用户ID和CQ表情 + add_user_msg = f"✨ 成员变动 ✨\n@{user_id}欢迎主人进群喵~[CQ:face,id=175]" else: - add_user_msg = f"✨ 成员变动 ✨\n欢迎[CQ:at,qq={user_id}]的加入喵~\n加入时间:⌈{add_time}⌋,请在群内积极发言喵~" \ + # 如果是普通用户加入群组,生成通用的欢迎消息,包含用户ID、加入时间和用户头像图片的链接 + add_user_msg = f"✨ 成员变动 ✨\n欢迎@{user_id}的加入喵~\n加入时间:⌈{add_time}⌋,请在群内积极发言喵~" \ f"[CQ:image,file=https://q4.qlogo.cn/headimg_dl?dst_uin={user_id}&spec=640]" + return add_user_msg + diff --git a/nonebot_plugin_eventmonitor/handle.py b/nonebot_plugin_eventmonitor/handle.py new file mode 100644 index 0000000..d9c7e67 --- /dev/null +++ b/nonebot_plugin_eventmonitor/handle.py @@ -0,0 +1,192 @@ +import nonebot +from nonebot.rule import Rule +from nonebot.matcher import Matcher +from nonebot.plugin import on_notice, on_command +from nonebot.permission import SUPERUSER +from nonebot.adapters.onebot.v11.permission import GROUP_OWNER, GROUP_ADMIN +from nonebot.adapters.onebot.v11 import ( + Bot, Event, Message, + PokeNotifyEvent, + HonorNotifyEvent, + GroupUploadNoticeEvent, + GroupDecreaseNoticeEvent, + GroupIncreaseNoticeEvent, + GroupAdminNoticeEvent, + LuckyKingNotifyEvent, + MessageSegment, + GroupMessageEvent +) + +from .stamp import chuo_send_msg +from .honour import monitor_rongyu +from .admin import del_user_bye, add_user_wecome, admin_changer +from .utils import * + + +# 获取戳一戳状态 +async def _is_poke(event: Event) -> bool: + return isinstance(event, PokeNotifyEvent) and event.is_tome() +# 获取群荣誉变更 +async def _is_rongyu(event: Event) -> bool: + return isinstance(event, HonorNotifyEvent) +# 获取文件上传 +async def _is_checker(event: Event) -> bool: + return isinstance(event, GroupUploadNoticeEvent) +# 群成员减少 +async def _is_del_user(event: Event) -> bool: + return isinstance(event, GroupDecreaseNoticeEvent) +# 群成员增加 +async def _is_add_user(event: Event) -> bool: + return isinstance(event, GroupIncreaseNoticeEvent) +# 管理员变动 +async def _is_admin_change(event: Event) -> bool: + return isinstance(event, GroupAdminNoticeEvent) +# 红包运气王 +async def _is_red_packet(event: Event) -> bool: + return isinstance(event, LuckyKingNotifyEvent) + +# 戳一戳 +chuo = on_notice(Rule(_is_poke), priority=50, block=True) +# 群荣誉 +qrongyu = on_notice(Rule(_is_rongyu), priority=50, block=True) +# 群文件 +files = on_notice(Rule(_is_checker), priority=50, block=True) +# 群员减少 +del_user = on_notice(Rule(_is_del_user), priority=50, block=True) +# 群员增加 +add_user = on_notice(Rule(_is_add_user), priority=50, block=True) +# 群管理 +group_admin = on_notice(Rule(_is_admin_change), priority=50, block=True) +# 红包 +red_packet = on_notice(Rule(_is_red_packet), priority=50, block=True) +# 功能开关 +switch_command = on_command("开启", aliases={"关闭"}, + permission=SUPERUSER | GROUP_ADMIN | GROUP_OWNER, + priority=10, + block=False + ) +#功能状态 +state = on_command("event配置", aliases={"event状态"}, + permission=SUPERUSER | GROUP_ADMIN | GROUP_OWNER, + priority=10, + block=False + ) +#初始化配置配置文件 +@driver.on_bot_connect +async def _(): + await init(g_temp) + await config_check() + +@chuo.handle() +async def send_chuo(event: PokeNotifyEvent): + if not (await check_chuo(g_temp, str(event.group_id))): + await chuo.finish(notAllow, at_sender=True) + # 获取用户id + uid = event.get_user_id() + # 计算cd + try: + cd = event.time - chuo_CD_dir[uid] + except KeyError: + # 没有记录则cd为cd_time+1 + cd = chuo_cd + 1 + if ( + cd > chuo_cd + or event.get_user_id() in nonebot.get_driver().config.superusers + ):# 记录cd + chuo_CD_dir.update({uid: event.time}) + rely_msg = await chuo_send_msg() + await chuo.finish(message=Message(rely_msg)) +#群荣誉变化 +@qrongyu.handle() +async def send_rongyu(event: HonorNotifyEvent, bot: Bot): + if not (await check_honor(g_temp, str(event.group_id))): + await qrongyu.finish(notAllow, at_sender=True) + bot_qq = int(bot.self_id) + rely_msg = await monitor_rongyu(event.honor_type, event.user_id, bot_qq) + await qrongyu.finish(message=Message(rely_msg)) +#上传群文件 +@files.handle() +async def handle_first_receive(event: GroupUploadNoticeEvent): + if not (await check_file(g_temp, str(event.group_id))): + await files.finish(notAllow, at_sender=True) + rely = MessageSegment.at(event.user_id) + '\n' + \ + MessageSegment.image(f'https://q4.qlogo.cn/headimg_dl?dst_uin={event.user_id}&spec=640') + \ + '\n 上传了新文件,感谢你一直为群里做贡献喵~' + MessageSegment.face(175) + await files.finish(message=rely) +#退群事件 +@del_user.handle() +async def user_bye(event: GroupDecreaseNoticeEvent): + if not (await check_del_user(g_temp, str(event.group_id))): + await del_user.finish(notAllow, at_sender=True) + rely_msg = await del_user_bye(event.time, event.user_id) + await del_user.finish(message=Message(rely_msg)) +#入群事件 +@add_user.handle() +async def user_welcome(event: GroupIncreaseNoticeEvent, bot: Bot): + if not (await check_add_user(g_temp, str(event.group_id))): + await add_user.finish(notAllow, at_sender=True) + bot_qq = int(bot.self_id) + rely_msg = await add_user_wecome(event.time, event.user_id, bot_qq) + await add_user.finish(message=Message(rely_msg)) +#管理员变动 +@group_admin.handle() +async def admin_chance(event: GroupAdminNoticeEvent, bot: Bot): + if not (await check_admin(g_temp, str(event.group_id))): + await group_admin.finish(notAllow, at_sender=True) + bot_qq = int(bot.self_id) + rely_msg = await admin_changer(event.sub_type, event.user_id, bot_qq) + await group_admin.finish(message=Message(rely_msg)) +#红包运气王 +@red_packet.handle() +async def hongbao(event: LuckyKingNotifyEvent): + if not (await check_red_package(g_temp, str(event.group_id))): + await red_packet.finish(notAllow, at_sender=True) + rely_msg = MessageSegment.at(event.user_id) + "\n" + "本次红包运气王为:" + MessageSegment.at(event.target_id) + await red_packet.finish(message=rely_msg) + + +def get_command_type(command: str) -> str: + """根据指令内容获取开关类型""" + return next( + ( + key + for key, keywords in path.items() + if any(keyword in command for keyword in keywords) + ), + "", + ) + +@switch_command.handle() +async def switch(event: GroupMessageEvent, matcher: Matcher): + # 获取开关指令的参数,即用户输入的指令内容 + command = str(event.get_message()).strip() + # 获取群组ID + gid = str(event.group_id) + # 判断指令是否包含"开启"或"关闭"关键字 + if "开启" in command or "开始" in command: + if key := get_command_type(command): + g_temp[gid][key] = True + write_group_data(g_temp) + name = get_function_name(key) + await switch_command.finish(f"{name}功能已开启喵") + elif "禁止" in command or "关闭" in command: + if key := get_command_type(command): + g_temp[gid][key] = False + write_group_data(g_temp) + name = get_function_name(key) + await switch_command.finish(f"{name}功能已禁用喵") + +@state.handle() +async def event_state(event:GroupMessageEvent, matcher: Matcher): + gid = str(event.group_id) + with open(address, "r", encoding="utf-8") as f: + group_status = json.load(f) + if gid not in group_status: + await config_check() + else: + await matcher.finish(f"群{gid}的Event配置状态:\n" + "\n".join + ( + [f"{path[func][0]}: {'开启' if group_status[gid][func] else '关闭'}" for func in + path] + ) + ) \ No newline at end of file diff --git a/nonebot_plugin_eventmonitor/honour.py b/nonebot_plugin_eventmonitor/honour.py index c3ff157..4859a16 100644 --- a/nonebot_plugin_eventmonitor/honour.py +++ b/nonebot_plugin_eventmonitor/honour.py @@ -1,30 +1,41 @@ from .utils import superusers -async def monitor_rongyu(honor_type, user_id, bot_qq): - rely = "" - +async def monitor_rongyu(honor_type, user_id, bot_qq): + rely = "" + # 根据honor_type选择不同的消息 if honor_type == "emotion": + # 如果用户ID等于机器人的QQ号,不作任何操作 if user_id == bot_qq: pass + # 如果用户ID在superusers列表中,返回特定消息 elif user_id in superusers: - rely = f"[CQ:at,qq={user_id}]恭喜主人荣获快乐源泉🤣标识喵~" + rely = f"@{user_id}恭喜主人荣获快乐源泉🤣标识喵~" + # 否则,返回通用消息 else: - rely = f"恭喜[CQ:at,qq={user_id}]荣获快乐源泉🤣标识喵~" + rely = f"恭喜@{user_id}荣获快乐源泉🤣标识喵~" + elif honor_type == "performer": + # 如果用户ID等于机器人的QQ号,不作任何操作 if user_id == bot_qq: pass + # 如果用户ID在superusers列表中,返回特定消息 elif user_id in superusers: - rely = f"[CQ:at,qq={user_id}]恭喜主人荣获群聊之火🔥标识喵~" + rely = f"@{user_id}恭喜主人荣获群聊之火🔥标识喵~" + # 否则,返回通用消息 else: - rely = f"恭喜[CQ:at,qq={user_id}]荣获群聊之火🔥标识喵~" + rely = f"恭喜@{user_id}荣获群聊之火🔥标识喵~" elif honor_type == "talkative": + # 如果用户ID等于机器人的QQ号,返回特定消息 if user_id == bot_qq: rely = "你们又不行了,本喵喜提龙王🐲~" + # 如果用户ID在superusers列表中,返回特定消息 elif user_id in superusers: - rely = f"[CQ:at,qq={user_id}]恭喜主人荣获龙王🐲标识喵~" + rely = f"@{user_id}恭喜主人荣获龙王🐲标识喵~" + # 否则,返回通用消息 else: - rely = f"恭喜[CQ:at,qq={user_id}]荣获龙王🐲标识喵~" + rely = f"恭喜@{user_id}荣获龙王🐲标识喵~" return rely + diff --git a/nonebot_plugin_eventmonitor/stamp.py b/nonebot_plugin_eventmonitor/stamp.py index 959b9d0..2d8debf 100644 --- a/nonebot_plugin_eventmonitor/stamp.py +++ b/nonebot_plugin_eventmonitor/stamp.py @@ -3,10 +3,12 @@ async def chuo_send_msg(): - rand_num = random.randint(0, len(chuo_msg) - 1) + # 使用 random.randint() 生成一个随机整数,作为选择消息的索引 + rand_num = random.randint(0, len(chuo_msg) - 1) + # 返回位于随机索引处的消息 return chuo_msg[rand_num] - +#戳一戳文案 chuo_msg = [ f"别戳了,{nickname}怕疼QwQ", f"呜呜,再戳{nickname}脸都要肿了", diff --git a/setup.py b/setup.py index e7d222f..90317fb 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="nonebot_plugin_eventmonitor", - version="0.1.7", + version="0.1.8", author="schwarzwald", description="监控群事件的插件,支持戳一戳,成员变动,群荣誉,运气王变化等提示", long_description=long_description,