koishi-plugin-status
Advanced tools
Comparing version 2.0.0-beta.3 to 2.0.0-beta.4
@@ -6,5 +6,3 @@ import { Context, App } from 'koishi-core'; | ||
} | ||
} | ||
declare module 'koishi-core/dist/sender' { | ||
interface CQSender { | ||
interface Bot { | ||
counter: number[]; | ||
@@ -19,3 +17,2 @@ } | ||
export interface StatusOptions { | ||
sort?: (a: BotStatus, b: BotStatus) => number; | ||
} | ||
@@ -45,5 +42,5 @@ export interface Rate { | ||
GOOD = 0, | ||
CQ_ERROR = 1, | ||
NET_ERROR = 2, | ||
IDLE = 3 | ||
IDLE = 1, | ||
CQ_ERROR = 2, | ||
NET_ERROR = 3 | ||
} | ||
@@ -50,0 +47,0 @@ export declare const name = "status"; |
@@ -44,11 +44,8 @@ "use strict"; | ||
const startTime = Date.now(); | ||
const defaultConfig = { | ||
sort: () => 0, | ||
}; | ||
var StatusCode; | ||
(function (StatusCode) { | ||
StatusCode[StatusCode["GOOD"] = 0] = "GOOD"; | ||
StatusCode[StatusCode["CQ_ERROR"] = 1] = "CQ_ERROR"; | ||
StatusCode[StatusCode["NET_ERROR"] = 2] = "NET_ERROR"; | ||
StatusCode[StatusCode["IDLE"] = 3] = "IDLE"; | ||
StatusCode[StatusCode["IDLE"] = 1] = "IDLE"; | ||
StatusCode[StatusCode["CQ_ERROR"] = 2] = "CQ_ERROR"; | ||
StatusCode[StatusCode["NET_ERROR"] = 3] = "NET_ERROR"; | ||
})(StatusCode = exports.StatusCode || (exports.StatusCode = {})); | ||
@@ -58,3 +55,2 @@ exports.name = 'status'; | ||
const app = ctx.app; | ||
config = { ...defaultConfig, ...config }; | ||
app.on('before-command', ({ session }) => { | ||
@@ -103,5 +99,5 @@ session.$user['lastCall'] = new Date(); | ||
.shortcut('运行状态', { prefix: true }) | ||
.action(async ({ session }) => { | ||
.action(async () => { | ||
const { bots: apps, cpu, memory, startTime, userCount, groupCount } = await getStatus(config); | ||
const output = apps.sort(config.sort).map(({ label, selfId, code, rate }) => { | ||
const output = apps.map(({ label, selfId, code, rate }) => { | ||
return `${label || selfId}:${code ? '无法连接' : `工作中(${rate}/min)`}`; | ||
@@ -122,3 +118,3 @@ }); | ||
label: bot.label, | ||
code: bot._get ? await bot.getStatus().then(({ good }) => good ? StatusCode.GOOD : StatusCode.CQ_ERROR, () => StatusCode.NET_ERROR) : StatusCode.IDLE, | ||
code: await bot.getStatus(), | ||
rate: bot.counter.slice(1).reduce((prev, curr) => prev + curr, 0), | ||
@@ -125,0 +121,0 @@ }))), |
{ | ||
"name": "koishi-plugin-status", | ||
"description": "Show Status of Koishi", | ||
"version": "2.0.0-beta.3", | ||
"version": "2.0.0-beta.4", | ||
"main": "dist/index.js", | ||
@@ -18,6 +18,6 @@ "typings": "dist/index.d.ts", | ||
"type": "git", | ||
"url": "git+https://github.com/koishijs/plugins.git" | ||
"url": "git+https://github.com/koishijs/koishi.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/koishijs/plugins/issues" | ||
"url": "https://github.com/koishijs/koishi/issues" | ||
}, | ||
@@ -38,9 +38,9 @@ "homepage": "https://github.com/koishijs/plugins/plugin-status#readme", | ||
"koishi-plugin-mysql": "^2.0.0-beta.2", | ||
"koishi-test-utils": "^4.0.0-beta.2" | ||
"koishi-test-utils": "^4.0.0-beta.3" | ||
}, | ||
"dependencies": { | ||
"cross-spawn": "^7.0.3", | ||
"koishi-core": "^2.0.0-beta.5", | ||
"koishi-core": "^2.0.0-beta.6", | ||
"koishi-utils": "^2.1.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
25785
355
Updatedkoishi-core@^2.0.0-beta.6