Skip to content

Commit

Permalink
OneBotDocking添加监听onClientDestroy
Browse files Browse the repository at this point in the history
OneBotDocking监听改名:onClientClose=>onClientDisconnect
  • Loading branch information
timiya2333 committed Apr 4, 2023
1 parent 348e8a2 commit 8b1c318
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
23 changes: 3 additions & 20 deletions Release-Description.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
# TMBot Release Note

#### Version 1.0.2
#### Version 1.0.4

## 更新描述:无

## 修复Bug

1. 修复因为更换ws库的原因造成旧代码的重连bug

## 新增特性

###

1. 为底层ws客户端类添加监听onDestroy
2. 为Version添加debug属性,插件可自觉判断并做出一些操作(将FileClass的debug输出给弄到这里了)

***
请在你正在使用的WS实例销毁时一并结束你的插件的一切工作,Example:

```
let tmp = BotDockingMgr.getBot("xxx");
let sid = setInterval(()=>{},1000);
tmp.Client.events.onDestroy.on(()=>{
clearInterval(sid);
})
```

***
1. OneBotDocking添加监听onClientDestroy(同 WebsocketClient.event.onDestroy)
2. OneBotDocking监听改名: onClientClose => onClientDisconnect
2 changes: 1 addition & 1 deletion app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let Logo = String.raw`
let logger = new Logger("TMBotMain");

export let Version = {
"version": [1, 0, 3],
"version": [1, 0, 4],
"isBeta": true,
"isDebug": false
};
Expand Down
10 changes: 8 additions & 2 deletions modules/OneBotDocking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,8 @@ export class OneBotDocking {
private _events = {
"onRawMessage": new Event<(rawInfo: string, ori: (isExecute: boolean, raw: string) => void) => void>(this.DelayLogger),
"onInitSuccess": new Event<() => void>(this.DelayLogger),
"onClientClose": new Event<() => void>(this.DelayLogger),
"onClientDisconnect": new Event<() => void>(this.DelayLogger),
"onClientDestroy": new Event<() => void>(this.DelayLogger),
"onClientStatusChanged": new Event<(device: DeviceInfo, online: boolean) => void>(this.DelayLogger),
"onPrivateMsg": new Event<(senderInfo: SenderInfo, sub_type: "friend" | "group" | "discuss" | "other", msgInfo: MsgInfo) => void>(this.DelayLogger),
"onGroupMsg": new Event<(groupInfo: GroupInfo, sub_type: "normal" | "anonymous" | "notice", groupMemberInfo: GroupMemberInfo | AnonymousInfo, msgInfo: MsgInfo) => void>(this.DelayLogger),
Expand Down Expand Up @@ -1004,7 +1005,12 @@ export class OneBotDocking {
});
this.wsc.events.onClose.on((code, desc) => {
// this.logger.warn(`WS已断开!退出码: ${code}, DESC:${desc}`);
this._events.onClientClose.fire(
// this._events.onClientClose.fire(
// "OneBotDockingProcess_Event_ClientClose"
// );
});
this.wsc.events.onDestroy.on(() => {
this._events.onClientDestroy.fire(
"OneBotDockingProcess_Event_ClientClose"
);
});
Expand Down

0 comments on commit 8b1c318

Please sign in to comment.