From ddbd03dc1ea0fd26bbfc1159a46732b6e5faf402 Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Mon, 24 Mar 2025 10:40:20 +0800 Subject: [PATCH 1/4] Adds sticker handling in Telegram adapter --- astrbot/core/platform/sources/telegram/tg_adapter.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/astrbot/core/platform/sources/telegram/tg_adapter.py b/astrbot/core/platform/sources/telegram/tg_adapter.py index 93ed6feb6..1b26e9ebe 100644 --- a/astrbot/core/platform/sources/telegram/tg_adapter.py +++ b/astrbot/core/platform/sources/telegram/tg_adapter.py @@ -199,6 +199,15 @@ class TelegramPlatformAdapter(Platform): ] message.message.append(Comp.At(qq=name, name=name)) + elif update.message.sticker: + # 将sticker当作图片处理 + file = await update.message.sticker.get_file() + message.message.append(Comp.Image(file=file.file_path, url=file.file_path)) + if update.message.sticker.emoji: + sticker_text = f"Sticker: {update.message.sticker.emoji}" + message.message_str = sticker_text + message.message.append(Comp.Plain(sticker_text)) + elif update.message.document: file = await update.message.document.get_file() message.message = [ From 08528510efa11b5493869876b269b4dade01c48b Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Mon, 24 Mar 2025 10:41:33 +0800 Subject: [PATCH 2/4] Fix incorrect handling of reply messages within topics --- astrbot/core/platform/sources/telegram/tg_adapter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/astrbot/core/platform/sources/telegram/tg_adapter.py b/astrbot/core/platform/sources/telegram/tg_adapter.py index 1b26e9ebe..b12478d5f 100644 --- a/astrbot/core/platform/sources/telegram/tg_adapter.py +++ b/astrbot/core/platform/sources/telegram/tg_adapter.py @@ -133,7 +133,11 @@ class TelegramPlatformAdapter(Platform): message.message_str = "" message.message = [] - if update.message.reply_to_message: + if update.message.reply_to_message and not ( + update.message.is_topic_message + and update.message.message_thread_id + == update.message.reply_to_message.message_id + ): # 获取回复消息 reply_update = Update( update_id=1, From 0500ff333a791d7753f606282bac6881434b70ed Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 02:50:27 +0000 Subject: [PATCH 3/4] :balloon: auto fixes by pre-commit hooks --- astrbot/dashboard/routes/stat.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/astrbot/dashboard/routes/stat.py b/astrbot/dashboard/routes/stat.py index 04b2d21ee..a74187977 100644 --- a/astrbot/dashboard/routes/stat.py +++ b/astrbot/dashboard/routes/stat.py @@ -69,10 +69,10 @@ class StatRoute(Route): process = psutil.Process() # 获取系统CPU使用率而不是进程CPU使用率 cpu_percent = psutil.cpu_percent(interval=0.5) - + # 获取线程数 thread_count = threading.active_count() - + # 获取插件信息 plugins = self.core_lifecycle.star_context.get_all_stars() plugin_info = [] @@ -80,7 +80,7 @@ class StatRoute(Route): info = { "name": getattr(plugin, "name", plugin.__class__.__name__), "version": getattr(plugin, "version", "1.0.0"), - "is_enabled": True + "is_enabled": True, } plugin_info.append(info) From b234856b0237ff60f045e91b9d970d108c1ae1db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A1=E9=B8=A695676?= Date: Mon, 24 Mar 2025 11:36:46 +0800 Subject: [PATCH 4/4] Remove unused variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除以通过ruff检查 在Ubuntu24.04LTS中,移除未见对现有功能的影响 --- astrbot/dashboard/routes/stat.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/astrbot/dashboard/routes/stat.py b/astrbot/dashboard/routes/stat.py index a74187977..5c197fad7 100644 --- a/astrbot/dashboard/routes/stat.py +++ b/astrbot/dashboard/routes/stat.py @@ -65,8 +65,6 @@ class StatRoute(Route): stat_dict = stat.__dict__ - # 获取CPU使用率 - 修复CPU始终为0的问题 - process = psutil.Process() # 获取系统CPU使用率而不是进程CPU使用率 cpu_percent = psutil.cpu_percent(interval=0.5)