Open
Conversation
huoxue1
commented
Mar 28, 2023
- 在openEventListenChan直接在chan中预添加连接事件 huoxue1@6c14241
- 在handleRequest时添加上下文管理和panic的recover huoxue1@3f2c4ed
Author
|
已经在这里导入测试了下应该没啥问题 |
stdrc
reviewed
Apr 22, 2023
Comment on lines
+95
to
+104
| type VersionStruct struct { | ||
| Impl string `json:"impl"` | ||
| Version string `json:"version"` | ||
| OnebotVersion string `json:"onebot_version"` | ||
| } | ||
|
|
||
| type ConnectMetaEvent struct { | ||
| MetaEvent | ||
| Version VersionStruct `json:"version"` | ||
| } |
| } | ||
| } | ||
|
|
||
| type VersionStruct struct { |
| if _, ok := err.(error); ok { | ||
| w.WriteFailed(RetCodeInternalHandlerError, err.(error)) | ||
| } | ||
| ob.Logger.Errorf("处理%v时出现异常:%#v", r.Action, err) |
Member
There was a problem hiding this comment.
原谅我强迫症,这里需要注意一下空格和符号跟其他地方一致
"处理 %v 时出现异常: %#v"
Comment on lines
+44
to
+53
| ch := make(chan marshaledEvent, 1) // 设置缓冲区为1,因为需要先放入一个连接事件 | ||
| connectMetaEvent := MakeConnectMetaEvent(ob.Impl, Version, OneBotVersion) | ||
| ob.Logger.Debugf("事件: %#v", connectMetaEvent) | ||
| ob.Logger.Infof("事件 `%v` 开始推送", connectMetaEvent.Name()) | ||
| eventBytes, _ := json.Marshal(connectMetaEvent) | ||
| ch <- marshaledEvent{ | ||
| name: connectMetaEvent.Name(), | ||
| bytes: eventBytes, | ||
| raw: &connectMetaEvent, | ||
| } |
Member
There was a problem hiding this comment.
connect 事件应该只在 WS 和反向 WS 的时候产生,可能最好在 comm_ws.go 和 comm_ws_reverse.go 创建 eventChan 之后,开始 loop 之前创建并推送
| // params: 动作参数, 若传入 nil 则实际动作参数为空 map | ||
| // | ||
| // action: 要调用的动作名称 | ||
| // params: 动作参数, 若传入 nil 则实际动作参数为空 map |
Member
There was a problem hiding this comment.
似乎 gofmt 对注释的参数也开始格式化了,如果想再水个 pr 的话可以开个 pr 格式化所有代码🤓
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.