diff --git a/ATRI/config.py b/ATRI/config.py index b911a836..bbd5354a 100644 --- a/ATRI/config.py +++ b/ATRI/config.py @@ -59,7 +59,6 @@ class Setu: "command_start": BotSelfConfig.command_start, "command_sep": BotSelfConfig.command_sep, "session_expire_timeout": BotSelfConfig.session_expire_timeout, - "gocq_accounts": InlineGoCQHTTP.accounts, "gocq_version": InlineGoCQHTTP.download_version, } diff --git a/ATRI/plugins/broadcast.py b/ATRI/plugins/broadcast.py index 0948e312..b12c0504 100644 --- a/ATRI/plugins/broadcast.py +++ b/ATRI/plugins/broadcast.py @@ -32,7 +32,7 @@ class BroadCast(Service): def __init__(self): Service.__init__(self, "广播", "向bot所在的所有群发送信息", True, to_bot()) - + @staticmethod def load_rej_list() -> list: data = list() @@ -41,20 +41,22 @@ def load_rej_list() -> list: with open(path, "w", encoding="utf-8") as w: w.write(json.dumps(data)) return data - + return json.loads(path.read_bytes()) - + @classmethod def store_rej_list(cls, data: list): - path = BC_PATH/ "rej_list.json" + path = BC_PATH / "rej_list.json" if not path.is_file(): cls.load_rej_list() - + with open(path, "w", encoding="utf-8") as w: w.write(json.dumps(data)) -caster = BroadCast().on_command("广播", "向bot所在的所有群发送信息,有防寄延迟", aliases={"/bc","bc"}, permission=SUPERUSER) +caster = BroadCast().on_command( + "广播", "向bot所在的所有群发送信息,有防寄延迟", aliases={"/bc", "bc"}, permission=SUPERUSER +) @caster.handle() @@ -81,20 +83,22 @@ async def _(bot: Bot, event: MessageEvent, s_msg: str = ArgPlainText("bc_msg")): su_g.append(group_id) except: fl_g.append(group_id) - + await asyncio.sleep(random.randint(2, 3)) - + repo_msg = _BROADCAST_BACK.format( msg=s_msg, len_g=len(w_group), su_g=su_g, fl_g=fl_g, - f_g="、".join(map(str, fl_g)) + f_g="、".join(map(str, fl_g)), ) await caster.finish(repo_msg) -rej_broadcast = BroadCast().on_command("拒绝广播", "拒绝来自开发者的广播推送", permission=GROUP_OWNER | GROUP_ADMIN) +rej_broadcast = BroadCast().on_command( + "拒绝广播", "拒绝来自开发者的广播推送", permission=GROUP_OWNER | GROUP_ADMIN +) @rej_broadcast.handle() @@ -109,12 +113,15 @@ async def _(bot: Bot, event: GroupMessageEvent): BroadCast().store_rej_list(rej_g) await rej_broadcast.finish("完成~!已将本群列入推送黑名单") + @rej_broadcast.handle() async def _(event: PrivateMessageEvent): await rej_broadcast.finish("该功能仅在群聊中触发...") -acc_broadcast = BroadCast().on_command("接受广播", "接受来自开发者的广播推送", permission=GROUP_OWNER | GROUP_ADMIN) +acc_broadcast = BroadCast().on_command( + "接受广播", "接受来自开发者的广播推送", permission=GROUP_OWNER | GROUP_ADMIN +) @acc_broadcast.handle() @@ -129,6 +136,7 @@ async def _(bot: Bot, event: GroupMessageEvent): else: await rej_broadcast.finish("本群不在推送黑名单里呢...") + @acc_broadcast.handle() async def _(event: PrivateMessageEvent): await rej_broadcast.finish("该功能仅在群聊中触发...") diff --git a/ATRI/plugins/essential.py b/ATRI/plugins/essential.py index 6d981aab..e3919d59 100644 --- a/ATRI/plugins/essential.py +++ b/ATRI/plugins/essential.py @@ -24,7 +24,7 @@ GroupRecallNoticeEvent, FriendRecallNoticeEvent, MessageSegment, - Message + Message, ) import ATRI @@ -302,7 +302,7 @@ async def _recall_private_event(bot: Bot, event: FriendRecallNoticeEvent): repo = await bot.get_msg(message_id=event.message_id) except BaseException: return - + user = event.user_id repo: dict = repo["message"] @@ -315,6 +315,7 @@ async def _recall_private_event(bot: Bot, event: FriendRecallNoticeEvent): rej_recall = Essential().on_command("拒绝撤回", "拒绝撤回信息", permission=SUPERUSER) + @rej_recall.handle() async def _(): global _acc_recall @@ -324,6 +325,7 @@ async def _(): acc_recall = Essential().on_command("接受撤回", "接受撤回信息", permission=SUPERUSER) + @acc_recall.handle() async def _(): global _acc_recall @@ -349,7 +351,7 @@ def recall_msg_dealer(msg: dict) -> str: if _type == "text": temp_m.append(_data["text"]) elif _type == "image": - url = _data["url"] + url = _data["url"] check = MessageChecker(url).check_image_url if check: temp_m.append(MessageSegment.image(url)) diff --git a/ATRI/plugins/setu/__init__.py b/ATRI/plugins/setu/__init__.py index 6c135aae..ee2fc6c0 100644 --- a/ATRI/plugins/setu/__init__.py +++ b/ATRI/plugins/setu/__init__.py @@ -23,7 +23,9 @@ @random_setu.handle() -async def _random_setu(bot: Bot, event: MessageEvent, matcher: Matcher, args: Message = CommandArg()): +async def _random_setu( + bot: Bot, event: MessageEvent, matcher: Matcher, args: Message = CommandArg() +): user_id = event.get_user_id() if not _setu_flmt.check(user_id): await random_setu.finish() @@ -49,6 +51,7 @@ async def _random_setu(bot: Bot, event: MessageEvent, matcher: Matcher, args: Me if msg: matcher.set_arg("r_rush_after_think", args) + @random_setu.got("r_rush_after_think") async def _(think: str = ArgPlainText("r_rush_after_think")): is_repo = will_think(think) @@ -58,12 +61,13 @@ async def _(think: str = ArgPlainText("r_rush_after_think")): await random_setu.finish(is_repo) - tag_setu = Setu().on_regex(r"来[张点丶份](.*?)的[涩色🐍]图", "根据提供的tag查找涩图") @tag_setu.handle() -async def _tag_setu(bot: Bot, event: MessageEvent, matcher: Matcher, args: Message = CommandArg()): +async def _tag_setu( + bot: Bot, event: MessageEvent, matcher: Matcher, args: Message = CommandArg() +): user_id = event.get_user_id() if not _setu_flmt.check(user_id): await random_setu.finish() @@ -247,7 +251,7 @@ async def _scheduler_setu(bot): def will_think(msg: str) -> str: if msg in _ag_l: return str() - + ag_jud = re.findall(_ag_patt, msg) if ag_jud: return str() diff --git a/ATRI/plugins/setu/data_source.py b/ATRI/plugins/setu/data_source.py index a26bbef4..d8ad00e4 100644 --- a/ATRI/plugins/setu/data_source.py +++ b/ATRI/plugins/setu/data_source.py @@ -9,8 +9,9 @@ LOLICON_URL = "https://api.lolicon.app/setu/v2" -DEFAULT_SETU = "https://i.pixiv.cat/img-original/img/2021/02/28/22/44/49/88124144_p0.jpg" - +DEFAULT_SETU = ( + "https://i.pixiv.cat/img-original/img/2021/02/28/22/44/49/88124144_p0.jpg" +) class Setu(Service): diff --git a/ATRI/utils/__init__.py b/ATRI/utils/__init__.py index 480d00e3..599e2293 100644 --- a/ATRI/utils/__init__.py +++ b/ATRI/utils/__init__.py @@ -83,7 +83,7 @@ def check_cq_code(self) -> bool: return True else: return True - + @property def check_image_url(self) -> bool: if self.tenc_gchat_url not in self.text: