🐛 Fix has no attribute when reply_to_message is ForumTopicCreated.
#96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题描述
在 Telegram 实现中,
event.reply_to_message有可能为ForumTopicCreated,从而在extract_reply抛出 has no attribute 异常。这是因为在 Telegram topic thread 中发送消息需要引用
💬 "Topic" was created(参考资料),也就是 Telegram 适配中的ForumTopicCreated类,而这个类不继承于MessageEvent,所以这个类就没有original_message从而抛出异常。最小复现示例及异常
解决方案
由于
ForumTopicCreated不是一类真正的消息事件,也没有message_id没办法初始化Reply类,因此选择在if event.reply_to_message后加入类型判断,这样即可解决问题