Replies: 1 comment
-
🎉 此实现已在 nonebot/nonebot2#510 中被添加到 NoneBot2 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
目前, NoneBot对
MessageSegment
与Message
对象的字符串格式化不够完善很多时候需要将
MessageSegment
转换成str
再转成Message
对象这样即带来了注入的风险, 也导致了性能的额外损耗
如果单纯使用运算符重载的
+
号, 则无法胜任较为复杂的字符串格式化工作所以我在这里提供一个从Python原生的
string.Formatter
类继承的字符串格式化类作为概念参考经过简单测试没有发现问题
本体代码如下:
这是一个mah adapter可用的demo:
欢迎大家前来进行测试和建议反馈
Beta Was this translation helpful? Give feedback.
All reactions