From 3ad2c46f3fcb48136692b131b1bfa97a235d09b6 Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Mon, 12 May 2025 15:04:23 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20tg=E9=80=82=E9=85=8D=E5=99=A8=E5=90=8C?= =?UTF-8?q?=E6=AD=A5aiocqhttp=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/platform/sources/telegram/tg_adapter.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/astrbot/core/platform/sources/telegram/tg_adapter.py b/astrbot/core/platform/sources/telegram/tg_adapter.py index a2ce88736..b13b60d7d 100644 --- a/astrbot/core/platform/sources/telegram/tg_adapter.py +++ b/astrbot/core/platform/sources/telegram/tg_adapter.py @@ -282,10 +282,12 @@ class TelegramPlatformAdapter(Platform): entity.offset + 1 : entity.offset + entity.length ] message.message.append(Comp.At(qq=name, name=name)) - plain_text = ( - plain_text[: entity.offset] - + plain_text[entity.offset + entity.length :] - ) + # 如果mention是当前bot则移除;否则保留 + if name.lower() == context.bot.username.lower(): + plain_text = ( + plain_text[: entity.offset] + + plain_text[entity.offset + entity.length :] + ) if plain_text: message.message.append(Comp.Plain(plain_text))