@aka_openclaw_plugin/mychat 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.js +1 -1
- package/{channel-BpMr77-3.js → channel-CxT4NkH-.js} +22 -4
- package/channel-plugin-api.js +1 -1
- package/package.json +1 -1
- package/setup-entry.js +1 -1
package/api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as tryGetMychatRuntime, i as setMychatRuntime, n as init_runtime, t as getMychatRuntime } from "./runtime-PfFuZ2Rm.js";
|
|
2
|
-
import { t as mychatPlugin } from "./channel-
|
|
2
|
+
import { t as mychatPlugin } from "./channel-CxT4NkH-.js";
|
|
3
3
|
//#region api.ts
|
|
4
4
|
init_runtime();
|
|
5
5
|
//#endregion
|
|
@@ -208,6 +208,9 @@ function createMychatHttpClient(params) {
|
|
|
208
208
|
return null;
|
|
209
209
|
}
|
|
210
210
|
},
|
|
211
|
+
async reportStatus(status) {
|
|
212
|
+
return await request("POST", "/api/bot/status", { status }) !== null;
|
|
213
|
+
},
|
|
211
214
|
async healthCheck() {
|
|
212
215
|
const url = `${base}/health`;
|
|
213
216
|
const start = Date.now();
|
|
@@ -4191,13 +4194,21 @@ async function monitorMychatProvider(ctx) {
|
|
|
4191
4194
|
lastError: null
|
|
4192
4195
|
});
|
|
4193
4196
|
logger?.info(`${prefix} bot connected botId=${readyBotSelf.botId}`);
|
|
4194
|
-
|
|
4197
|
+
try {
|
|
4198
|
+
await httpClient.reportStatus("online");
|
|
4199
|
+
logger?.info(`${prefix} reported status=online`);
|
|
4200
|
+
} catch (err) {
|
|
4201
|
+
logger?.warn(`${prefix} failed to report status: ${err}`);
|
|
4202
|
+
}
|
|
4203
|
+
ctx.abortSignal?.addEventListener("abort", async () => {
|
|
4195
4204
|
logger?.info(`${prefix} abort signal received, shutting down`);
|
|
4205
|
+
await httpClient.reportStatus("offline").catch(() => {});
|
|
4196
4206
|
lifecycle.shutdown();
|
|
4197
4207
|
setStatus({ connected: false });
|
|
4198
4208
|
});
|
|
4199
|
-
return { unsubscribe() {
|
|
4209
|
+
return { unsubscribe: async () => {
|
|
4200
4210
|
logger?.info(`${prefix} unsubscribe called, shutting down`);
|
|
4211
|
+
await httpClient.reportStatus("offline").catch(() => {});
|
|
4201
4212
|
lifecycle.shutdown();
|
|
4202
4213
|
setStatus({ connected: false });
|
|
4203
4214
|
} };
|
|
@@ -4335,14 +4346,21 @@ function createMychatPluginBase() {
|
|
|
4335
4346
|
accountId: ctx.accountId,
|
|
4336
4347
|
setStatus: ctx.setStatus
|
|
4337
4348
|
});
|
|
4338
|
-
|
|
4349
|
+
const result = await monitorMychatProvider({
|
|
4339
4350
|
cfg: ctx.cfg,
|
|
4340
4351
|
runtime: ctx.runtime,
|
|
4341
4352
|
account: ctx.account,
|
|
4342
4353
|
setStatus,
|
|
4343
4354
|
abortSignal: ctx.abortSignal,
|
|
4344
4355
|
log: ctx.log
|
|
4345
|
-
})
|
|
4356
|
+
});
|
|
4357
|
+
await new Promise((resolve) => {
|
|
4358
|
+
const originalUnsubscribe = result.unsubscribe;
|
|
4359
|
+
result.unsubscribe = () => {
|
|
4360
|
+
originalUnsubscribe();
|
|
4361
|
+
resolve();
|
|
4362
|
+
};
|
|
4363
|
+
});
|
|
4346
4364
|
} }
|
|
4347
4365
|
};
|
|
4348
4366
|
}
|
package/channel-plugin-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as mychatPlugin } from "./channel-
|
|
1
|
+
import { t as mychatPlugin } from "./channel-CxT4NkH-.js";
|
|
2
2
|
export { mychatPlugin };
|
package/package.json
CHANGED
package/setup-entry.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as mychatPlugin } from "./channel-
|
|
1
|
+
import { t as mychatPlugin } from "./channel-CxT4NkH-.js";
|
|
2
2
|
export { mychatPlugin };
|