From 2e2c8be00b145e729ef005d0376d83e4c3b39f65 Mon Sep 17 00:00:00 2001 From: iwumingz Date: Fri, 8 Apr 2022 09:39:46 +0800 Subject: [PATCH] Fix sender_chat bugs --- data/command.yml | 9 +++++++-- plugins/cc.py | 11 ++++++----- plugins/info.py | 16 ++++++++++++---- plugins/other.py | 2 +- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/data/command.yml b/data/command.yml index d6c2cb0..7f35e5c 100644 --- a/data/command.yml +++ b/data/command.yml @@ -75,7 +75,7 @@ speedtest: format: -speedtest <无|节点ID|list|update> usage: 服务器本地网络测速 -s: +sticker: cmd: s format: -s <无|emoji> or -s usage: @@ -115,5 +115,10 @@ diss: tg: cmd: tg - format: -biss + format: -tg usage: 舔狗语录 + +test: + cmd: t + format: -t + usage: 测试 \ No newline at end of file diff --git a/plugins/cc.py b/plugins/cc.py index 35407b2..2fd5b9e 100644 --- a/plugins/cc.py +++ b/plugins/cc.py @@ -46,14 +46,15 @@ async def cc(cli: Client, msg: Message): # 攻击次数 cc_times = cc_times if 1 <= cc_times <= CC_MAX_TIMES else CC_MAX_TIMES cc_msgs: List[int] = [] + from_user_id = replied_msg.from_user.id if replied_msg.from_user else replied_msg.sender_chat.id # 遍历和搜索消息 if msg.chat.type in TG_GROUPS: async for target in cli.search_messages( chat_id=msg.chat.id, limit=1000, - from_user=replied_msg.from_user.id, + from_user=from_user_id, ): - if target.message_id > 1 and target.from_user: + if target.message_id > 1 and (target.from_user or target.sender_chat): cc_msgs.append(target.message_id) if len(cc_msgs) == cc_times: break @@ -68,12 +69,12 @@ async def cc(cli: Client, msg: Message): if len(cc_msgs) > 0: await msg.edit_text("🔥 `Attacking ...`") shot = 0 - for n, target_id in enumerate(cc_msgs): + for n, cc_msg_id in enumerate(cc_msgs): try: res = await emoji_sender( cli=cli, chat_id=msg.chat.id, - msg_id=target_id, + msg_id=cc_msg_id, emoji=cc_emoji ) except FloodWait as e: @@ -81,7 +82,7 @@ async def cc(cli: Client, msg: Message): res = await emoji_sender( cli=cli, chat_id=msg.chat.id, - msg_id=target_id, + msg_id=cc_msg_id, emoji=cc_emoji ) diff --git a/plugins/info.py b/plugins/info.py index 6727527..4c6e5ac 100644 --- a/plugins/info.py +++ b/plugins/info.py @@ -10,14 +10,22 @@ async def get_id(_: Client, msg: Message): text = f"Message ID: `{msg.message_id}`\n\n" \ f"Chat Title: `{msg.chat.title}`\n" \ f"Chat Type: `{msg.chat.type}`\n" \ - f"Chat ID: `{msg.chat.id}`" + f"Chat ID: `{msg.chat.id}`" \ - if msg.reply_to_message: - user = msg.reply_to_message.from_user - text = f"Repiled Message ID: `{msg.reply_to_message.message_id}`\n\n" \ + replied_msg = msg.reply_to_message + if replied_msg and replied_msg.from_user: + user = replied_msg.from_user + text = f"Repiled Message ID: `{replied_msg.message_id}`\n\n" \ f"User Nick: `{get_fullname(user)}`\n"\ f"User Name: `@{user.username}`\n" \ f"User ID: `{user.id}`\n\n" \ f"{text}" + elif replied_msg and replied_msg.sender_chat: + sender_chat = replied_msg.sender_chat + text = f"Repiled Message ID: `{replied_msg.message_id}`\n\n" \ + f"Chat Title: `{sender_chat.title}`\n" \ + f"Chat Type: `{sender_chat.type}`\n" \ + f"Chat ID: `{sender_chat.id}`\n\n" \ + f"{text}" await msg.edit_text(text) diff --git a/plugins/other.py b/plugins/other.py index 19aed0b..91319b3 100644 --- a/plugins/other.py +++ b/plugins/other.py @@ -39,7 +39,7 @@ async def get_api(api: str, msg: Message) -> None: logger.error(e) continue words = f"{msg.reply_to_message.from_user.mention(style='md')} {text}" \ - if msg.reply_to_message else text + if msg.reply_to_message and msg.reply_to_message.from_user else text try: await msg.edit_text(words, parse_mode='md') except FloodWait as e: