Fix sender_chat bugs

This commit is contained in:
iwumingz 2022-04-08 09:39:46 +08:00
parent e30521badd
commit 2e2c8be00b
4 changed files with 26 additions and 12 deletions

View File

@ -75,7 +75,7 @@ speedtest:
format: -speedtest <无|节点ID|list|update> format: -speedtest <无|节点ID|list|update>
usage: 服务器本地网络测速 usage: 服务器本地网络测速
s: sticker:
cmd: s cmd: s
format: -s <无|emoji> or -s <sticker_set_title> <sticker_set_name> format: -s <无|emoji> or -s <sticker_set_title> <sticker_set_name>
usage: usage:
@ -115,5 +115,10 @@ diss:
tg: tg:
cmd: tg cmd: tg
format: -biss format: -tg
usage: 舔狗语录 usage: 舔狗语录
test:
cmd: t
format: -t
usage: 测试

View File

@ -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_times = cc_times if 1 <= cc_times <= CC_MAX_TIMES else CC_MAX_TIMES
cc_msgs: List[int] = [] 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: if msg.chat.type in TG_GROUPS:
async for target in cli.search_messages( async for target in cli.search_messages(
chat_id=msg.chat.id, limit=1000, 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) cc_msgs.append(target.message_id)
if len(cc_msgs) == cc_times: if len(cc_msgs) == cc_times:
break break
@ -68,12 +69,12 @@ async def cc(cli: Client, msg: Message):
if len(cc_msgs) > 0: if len(cc_msgs) > 0:
await msg.edit_text("🔥 `Attacking ...`") await msg.edit_text("🔥 `Attacking ...`")
shot = 0 shot = 0
for n, target_id in enumerate(cc_msgs): for n, cc_msg_id in enumerate(cc_msgs):
try: try:
res = await emoji_sender( res = await emoji_sender(
cli=cli, cli=cli,
chat_id=msg.chat.id, chat_id=msg.chat.id,
msg_id=target_id, msg_id=cc_msg_id,
emoji=cc_emoji emoji=cc_emoji
) )
except FloodWait as e: except FloodWait as e:
@ -81,7 +82,7 @@ async def cc(cli: Client, msg: Message):
res = await emoji_sender( res = await emoji_sender(
cli=cli, cli=cli,
chat_id=msg.chat.id, chat_id=msg.chat.id,
msg_id=target_id, msg_id=cc_msg_id,
emoji=cc_emoji emoji=cc_emoji
) )

View File

@ -10,14 +10,22 @@ async def get_id(_: Client, msg: Message):
text = f"Message ID: `{msg.message_id}`\n\n" \ text = f"Message ID: `{msg.message_id}`\n\n" \
f"Chat Title: `{msg.chat.title}`\n" \ f"Chat Title: `{msg.chat.title}`\n" \
f"Chat Type: `{msg.chat.type}`\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: replied_msg = msg.reply_to_message
user = msg.reply_to_message.from_user if replied_msg and replied_msg.from_user:
text = f"Repiled Message ID: `{msg.reply_to_message.message_id}`\n\n" \ 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 Nick: `{get_fullname(user)}`\n"\
f"User Name: `@{user.username}`\n" \ f"User Name: `@{user.username}`\n" \
f"User ID: `{user.id}`\n\n" \ f"User ID: `{user.id}`\n\n" \
f"{text}" 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) await msg.edit_text(text)

View File

@ -39,7 +39,7 @@ async def get_api(api: str, msg: Message) -> None:
logger.error(e) logger.error(e)
continue continue
words = f"{msg.reply_to_message.from_user.mention(style='md')} {text}" \ 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: try:
await msg.edit_text(words, parse_mode='md') await msg.edit_text(words, parse_mode='md')
except FloodWait as e: except FloodWait as e: