-
-
Notifications
You must be signed in to change notification settings - Fork 526
为缺少session_id字段的aiocqhttp消息提供一个默认值,防止报错 #1328
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
base: master
Are you sure you want to change the base?
Conversation
文件级别变更
提示和命令与 Sourcery 交互
自定义您的体验访问您的 仪表板 以:
获得帮助Original review guide in EnglishReviewer's Guide by SourceryThis pull request addresses an issue where Updated class diagram for AiocqhttpMessageEventclassDiagram
class AiocqhttpMessageEvent{
message_str: str
message_obj: AstrBotMessage
platform_meta: dict
session_id: str
bot: Any
+ __init__(message_str: str, message_obj: AstrBotMessage, platform_meta: dict, session_id: str, bot: Any)
}
class AstrBotMessage{
}
AiocqhttpMessageEvent -- AstrBotMessage : message_obj
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嘿 @Zhalslar - 我已经查看了你的更改 - 这里有一些反馈:
总体评论:
- 考虑使用
message.session_id if hasattr(message, 'session_id') else '114514'
以获得更好的可读性。
以下是我在审查期间查看的内容
- 🟢 一般问题:一切看起来都很好
- 🟢 安全性:一切看起来都很好
- 🟢 测试:一切看起来都很好
- 🟢 复杂性:一切看起来都很好
- 🟢 文档:一切看起来都很好
帮助我更有用!请点击每个评论上的 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English
Hey @Zhalslar - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider using
message.session_id if hasattr(message, 'session_id') else '114514'
for better readability.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -320,7 +320,7 @@ async def handle_msg(self, message: AstrBotMessage): | |||
message_str=message.message_str, | |||
message_obj=message, | |||
platform_meta=self.meta(), | |||
session_id=message.session_id, | |||
session_id=getattr(message, "session_id", "114514"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不建议在这里进行 workaround 处理。可以试试直接修改 _convert_handle_request_event()
。看了下是由于这个方法导致的所提到的报错。
修复了aiocqhttp消息缺少session_id字段时导致报错
Motivation
aiocqhttp的群邀请事件和加好友事件在构造成AiocqhttpMessageEvent时缺少session_id字段,导致报错,影响我写的插件
Modifications
在构造AiocqhttpMessageEvent时,若session_id不存在则提供一个默认值来使用:
async def handle_msg(self, message: AstrBotMessage):
message_event = AiocqhttpMessageEvent(
message_str=message.message_str,
message_obj=message,
platform_meta=self.meta(),
session_id=getattr(message, "session_id", "114514"),
bot=self.bot,
)
Check
好的,这是翻译成中文的 pull request 摘要:
Sourcery 总结
Bug 修复:
aiocqhttp
中由于缺少session_id
字段而导致群邀请和好友请求事件出错的问题,通过添加默认值'114514'
解决。Original summary in English
Summary by Sourcery
Bug Fixes: