Skip to content

Commit

Permalink
Fix: 修复 gocqhttp 的"上报数据类型"设置为 array 时罢工的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-snow committed Feb 23, 2023
1 parent 59b92bd commit 710091e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 1 addition & 2 deletions nonebot_plugin_admin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ class Config(BaseModel, extra=Extra.ignore):
callback_notice: bool = True # 是否在操作完成后在 QQ 返回提示
ban_rand_time_min: int = 60 # 随机禁言最短时间(s) default: 1分钟
ban_rand_time_max: int = 2591999 # 随机禁言最长时间(s) default: 30天: 60*60*24*30
group_recall: bool = False # 是否开启防撤回功能 #TODO: 加到开关管理?

This comment has been minimized.

Copy link
@yzyyz1387

yzyyz1387 Feb 24, 2023

Owner

这玩意已经单独有“开关放撤回了呀”

This comment has been minimized.

Copy link
@yzyyz1387

yzyyz1387 Feb 24, 2023

Owner

This comment has been minimized.

Copy link
@tom-snow

tom-snow Feb 24, 2023

Author Collaborator

哦哦,那我删掉



driver = get_driver()
global_config = driver.config
plugin_config = Config.parse_obj(global_config)



18 changes: 14 additions & 4 deletions nonebot_plugin_admin/group_recall.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
import json

from nonebot import on_notice
from nonebot.adapters.onebot.v11 import NoticeEvent, Bot
from nonebot.adapters.onebot.v11 import NoticeEvent, Bot, Message, MessageSegment

from .config import global_config
from pydantic import parse_obj_as
from .config import global_config, plugin_config

su = global_config.superusers
group_recall = plugin_config.group_recall


async def _group_recall(bot: Bot, event: NoticeEvent) -> bool:
# 有需要自行取消注释
# 有需要自行在配置文件中启用
if not group_recall:
return False
if event.notice_type == 'group_recall':
return True
return False
Expand All @@ -41,5 +45,11 @@ async def _(bot: Bot, event: NoticeEvent):
# 防撤回
recalled_message = await bot.get_msg(message_id=message_id)
recall_notice = f"检测到{operator_info['card'] if operator_info['card'] else operator_info['nickname']}({operator_info['user_id']})撤回了一条消息:\n\n"
await bot.send_group_msg(group_id=group_id, message=recall_notice + recalled_message['message'])
if not isinstance(recalled_message['message'], str):
_message = Message([MessageSegment.text(recall_notice), parse_obj_as(
MessageSegment, *recalled_message['message']
)])
else:
_message = recall_notice + recalled_message['message']
await bot.send_group_msg(group_id=group_id, message=_message)

0 comments on commit 710091e

Please sign in to comment.