Merge pull request #1276 from Raven95676/master

fix: 移除TG注册命令时的调试信息,注册命令时添加合法性校验
This commit is contained in:
渡鸦95676
2025-04-14 22:04:11 +08:00
committed by GitHub

View File

@@ -1,4 +1,5 @@
import asyncio
import re
import sys
import uuid
@@ -118,8 +119,6 @@ class TelegramPlatformAdapter(Platform):
if commands:
await self.client.set_my_commands(commands)
for cmd in commands:
logger.debug(f"已注册指令: /{cmd.command} - {cmd.description}")
except Exception as e:
logger.error(f"向 Telegram 注册指令时发生错误: {e!s}")
@@ -167,6 +166,10 @@ class TelegramPlatformAdapter(Platform):
if not cmd_name or cmd_name in skip_commands:
return None
if not re.match(r"^[a-z0-9_]+$", cmd_name) or len(cmd_name) > 32:
logger.warning(f"跳过无法注册的命令: {cmd_name}")
return None
# Build description.
description = handler_metadata.desc or (
f"指令组: {cmd_name} (包含多个子指令)" if is_group else f"指令: {cmd_name}"