批量修复 Topic Group

This commit is contained in:
xtaodada 2022-11-18 16:41:46 +08:00
parent 0bd62162aa
commit af98483d38
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
8 changed files with 38 additions and 15 deletions

View File

@ -18,5 +18,5 @@ async def at_admins(client: Client, message: Message):
say = message.arguments or "召唤本群所有管理员" say = message.arguments or "召唤本群所有管理员"
send_list = ' , '.join(admins) send_list = ' , '.join(admins)
await client.send_message(message.chat.id, "%s\n\n%s" % (say, send_list), await client.send_message(message.chat.id, "%s\n\n%s" % (say, send_list),
reply_to_message_id=message.reply_to_message_id) reply_to_message_id=message.reply_to_message_id or message.reply_to_top_message_id)
await message.safe_delete() await message.safe_delete()

View File

@ -22,7 +22,8 @@ async def audio_to_voice(bot: Client, message: Message):
await bot.send_voice( await bot.send_voice(
message.chat.id, message.chat.id,
audio, audio,
reply_to_message_id=message.id if message.audio else message.reply_to_message_id) reply_to_message_id=message.id if message.audio else (message.reply_to_message_id or
message.reply_to_top_message_id))
except Exception as e: except Exception as e:
await message.edit(f"转换为语音消息失败:{e}") await message.edit(f"转换为语音消息失败:{e}")
safe_remove(audio) safe_remove(audio)

View File

@ -69,7 +69,7 @@ async def upload_sticker(bot: Client, message: Message, sticker_set: StickerSet)
message.chat.id, message.chat.id,
f"{directory_name}.zip", f"{directory_name}.zip",
caption=sticker_set.set.short_name, caption=sticker_set.set.short_name,
reply_to_message_id=message.reply_to_message_id reply_to_message_id=message.reply_to_message_id or message.reply_to_top_message_id,
) )
safe_remove(f"{directory_name}.zip") safe_remove(f"{directory_name}.zip")
shutil.rmtree(directory_name) shutil.rmtree(directory_name)

View File

@ -20,5 +20,7 @@ async def httpcat(client: Client, message: Message, request: AsyncClient):
await client.send_photo( await client.send_photo(
message.chat.id, message.chat.id,
io, io,
reply_to_message_id=message.reply_to_message_id if message.outgoing else message.id) reply_to_message_id=(
message.reply_to_message_id or message.reply_to_top_message_id
) if message.outgoing else message.id)
await message.safe_delete() await message.safe_delete()

View File

@ -39,7 +39,10 @@ async def netease_search(keyword: str, message: Message):
await conv.mark_as_read() await conv.mark_as_read()
answer: Message = await conv.get_response(filters=filters.audio) answer: Message = await conv.get_response(filters=filters.audio)
await conv.mark_as_read() await conv.mark_as_read()
await answer.copy(message.chat.id, reply_to_message_id=message.reply_to_message_id) await answer.copy(
message.chat.id,
reply_to_message_id=message.reply_to_message_id or message.reply_to_top_message_id
)
await message.safe_delete() await message.safe_delete()
@ -49,7 +52,10 @@ async def netease_url(url: str, message: Message):
await conv.mark_as_read() await conv.mark_as_read()
answer: Message = await conv.get_response(filters=filters.audio) answer: Message = await conv.get_response(filters=filters.audio)
await conv.mark_as_read() await conv.mark_as_read()
await answer.copy(message.chat.id, reply_to_message_id=message.reply_to_message_id) await answer.copy(
message.chat.id,
reply_to_message_id=message.reply_to_message_id or message.reply_to_top_message_id
)
await message.safe_delete() await message.safe_delete()
@ -59,7 +65,10 @@ async def netease_id(music_id: str, message: Message):
await conv.mark_as_read() await conv.mark_as_read()
answer: Message = await conv.get_response(filters=filters.audio) answer: Message = await conv.get_response(filters=filters.audio)
await conv.mark_as_read() await conv.mark_as_read()
await answer.copy(message.chat.id, reply_to_message_id=message.reply_to_message_id) await answer.copy(
message.chat.id,
reply_to_message_id=message.reply_to_message_id or message.reply_to_top_message_id
)
await message.safe_delete() await message.safe_delete()

View File

@ -53,7 +53,10 @@ async def weather_pic(client: Client, message: Message):
async with client.conversation("PagerMaid_Modify_bot") as conv: async with client.conversation("PagerMaid_Modify_bot") as conv:
answer: Message = await conv.ask(f"/weather {text}") answer: Message = await conv.ask(f"/weather {text}")
await conv.mark_as_read() await conv.mark_as_read()
await answer.copy(message.chat.id, reply_to_message_id=message.reply_to_message_id) await answer.copy(
message.chat.id,
reply_to_message_id=message.reply_to_message_id or message.reply_to_top_message_id
)
await message.safe_delete() await message.safe_delete()
@ -67,7 +70,10 @@ async def weather_he(client: Client, message: Message):
async with client.conversation("PagerMaid_Modify_bot") as conv: async with client.conversation("PagerMaid_Modify_bot") as conv:
answer: Message = await conv.ask(f"/weather_he {text}") answer: Message = await conv.ask(f"/weather_he {text}")
await conv.mark_as_read() await conv.mark_as_read()
await answer.copy(message.chat.id, reply_to_message_id=message.reply_to_message_id) await answer.copy(
message.chat.id,
reply_to_message_id=message.reply_to_message_id or message.reply_to_top_message_id
)
await message.safe_delete() await message.safe_delete()
@ -78,7 +84,10 @@ async def az_tts(client: Client, message: Message, mode: str):
async with client.conversation("PagerMaid_Modify_bot") as conv: async with client.conversation("PagerMaid_Modify_bot") as conv:
answer: Message = await conv.ask(f"/tts {text} {mode}") answer: Message = await conv.ask(f"/tts {text} {mode}")
await conv.mark_as_read() await conv.mark_as_read()
await answer.copy(message.chat.id, reply_to_message_id=message.reply_to_message_id) await answer.copy(
message.chat.id,
reply_to_message_id=message.reply_to_message_id or message.reply_to_top_message_id
)
await message.safe_delete() await message.safe_delete()

View File

@ -17,8 +17,10 @@ async def weather_lite(request: AsyncClient, message: Message):
return await message.edit("请输入正确的城市名称") return await message.edit("请输入正确的城市名称")
with open("weather.png", "wb") as f: with open("weather.png", "wb") as f:
f.write(data.content) f.write(data.content)
await message.reply_photo("weather.png", await message.reply_photo(
reply_to_message_id=message.reply_to_message_id, "weather.png",
quote=False) reply_to_message_id=message.reply_to_message_id or message.reply_to_top_message_id,
quote=False
)
await message.safe_delete() await message.safe_delete()
safe_remove("weather.png") safe_remove("weather.png")

View File

@ -31,13 +31,13 @@ async def yv_lu(bot: Client, message: Message):
try: try:
await chat_response.copy( await chat_response.copy(
message.chat.id, message.chat.id,
reply_to_message_id=message.reply_to_message_id) reply_to_message_id=message.reply_to_message_id or message.reply_to_top_message_id)
except Flood as e: except Flood as e:
await sleep(e.value + 1) await sleep(e.value + 1)
with contextlib.suppress(Exception): with contextlib.suppress(Exception):
await chat_response.copy( await chat_response.copy(
message.chat.id, message.chat.id,
reply_to_message_id=message.reply_to_message_id) reply_to_message_id=message.reply_to_message_id or message.reply_to_top_message_id)
except Exception: except Exception:
pass pass
await message.safe_delete() await message.safe_delete()