fix: actions command stopped working

This commit is contained in:
草师傅 2025-08-02 18:41:13 +08:00
parent bb5f4d3154
commit 4340c07660
2 changed files with 20 additions and 14 deletions

View file

@ -6,16 +6,15 @@ from config import config
async def handle_actions(message: Message) -> None:
if not config.is_feature_enabled('actions', message.chat.id):
return
if not message.chat.type in ['group', 'supergroup']:
return
rawtext = message.text
from_user = message.from_user.mention_html(message.sender_chat.title) if message.sender_chat else message.from_user.mention_html()
replied_user = message.reply_to_message.from_user.mention_html(message.reply_to_message.sender_chat.title) if message.reply_to_message and message.reply_to_message.sender_chat else message.reply_to_message.from_user.mention_html()
# 防止识别成命令而被误触发
if rawtext.replace('/','',1).isascii() or '@' in rawtext:
print(rawtext.replace('/','',1).isascii())
return
elif " " in message.text:
from_user = message.from_user.mention_html(message.sender_chat.title) if message.sender_chat else message.from_user.mention_html()
replied_user = message.reply_to_message.from_user.mention_html(message.reply_to_message.sender_chat.title) if message.reply_to_message and message.reply_to_message.sender_chat else (message.reply_to_message.from_user.mention_html() if message.reply_to_message else None)
if " " in rawtext:
if rawtext.split(" ")[0].replace('/','',1).isascii():
return
await message.reply(f"{from_user} {rawtext.split(" ")[0].replace('/','')}{replied_user if message.reply_to_message else '自己' } {''.join(rawtext.split(" ")[1:])}",disable_web_page_preview=True)