bot/core/actions.py
2025-07-30 21:40:15 +08:00

23 lines
No EOL
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from aiogram.types import Message
from config import config
async def handle_actions(message: Message) -> None:
if not config.is_feature_enabled('actions', message.chat.id):
return
rawtext = message.text
# 防止识别成命令而被误触发
if rawtext.replace('/','',1).isalpha() or '@' in rawtext:
return
elif " " in message.text:
if rawtext.split(" ")[0].replace('/','',1).isalpha():
return
await message.reply(f"{message.from_user.mention_html()} {rawtext.split(" ")[0].replace('/','')}{message.reply_to_message.from_user.mention_html() if message.reply_to_message else '自己' } {''.join(rawtext.split(" ")[1:])}",disable_web_page_preview=True)
else:
await message.reply(f"{message.from_user.mention_html()} {message.text.replace('/','')}{message.reply_to_message.from_user.mention_html() if message.reply_to_message else '自己'}",disable_web_page_preview=True)
async def handle_reverse_actions(message: Message) -> None:
if not config.is_feature_enabled('actions', message.chat.id):
return
await message.reply(f"{message.from_user.mention_html()}{message.reply_to_message.from_user.mention_html()} {message.text.replace('\\','')}了!",disable_web_page_preview=True)