-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: message.extract_plain_text() 对中文与英文消息处理得到的纯文本不一致 #47
Comments
message.extract_plain_text()
对中文与英文消息处理得到的纯文本不一致
message.extract_plain_text()
对中文与英文消息处理得到的纯文本不一致
@nonebot/telegram |
附函数: def extract_plain_text(self) -> str:
"""提取消息内纯文本消息"""
return "".join(str(seg) for seg in self if seg.is_text()) |
此为 TrieRule 仅匹配第一个 MessageSegment,而 Telegram Adapter 中原生的 MessageEntity 被视为不同的 MessageSegment 所致。
NoneBot2 的更新解诀了此问题:nonebot/nonebot2#2419 |
感谢解释,以及感谢您的贡献。 |
操作系统
Windows
Python 版本
3.11.3
NoneBot 版本
2.0.0
适配器
nonebot-adapter-telegram
协议端
V2
描述问题
在使用 on_command 响应器里,对中文命令与英文命令调用
extract_plain_text
出现了两种不同的结果,其中对于中文命令,函数能获取到命令后紧接的字符,并去除了空白字符,但对于英文命令,函数保留了空白字符。代码参见截图,结果参见截图。
复现步骤
extract_plain_text
对文本进行处理。期望的结果
期望英文命令与中文命令一致,仅获取到非空白字符。
截图或日志
Tasks
The text was updated successfully, but these errors were encountered: