New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

koishi-plugin-status

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koishi-plugin-status - npm Package Compare versions

Comparing version 2.0.0-beta.16 to 2.0.0-beta.17

0

dist/database.d.ts

@@ -0,0 +0,0 @@ import { Session } from 'koishi-core';

@@ -0,0 +0,0 @@ "use strict";

6

dist/index.d.ts
import { Context, App, BotStatusCode } from 'koishi-core';
import { ActiveData } from './database';
export * from './database';
declare module 'koishi-core/dist/context' {
interface EventMap {
'status'(status: Status, output: string[]): void;
}
}
declare module 'koishi-core/dist/server' {

@@ -19,2 +14,3 @@ interface BotOptions {

refresh?: number;
output?: (status: Status) => string;
}

@@ -21,0 +17,0 @@ export interface Rate {

27

dist/index.js

@@ -57,6 +57,19 @@ "use strict";

const startTime = Date.now();
const defaultConfig = {
refresh: koishi_utils_1.Time.minute,
output({ bots, cpu, memory, startTime, activeUsers, activeGroups }) {
const output = bots
.filter(bot => bot.code !== koishi_core_1.BotStatusCode.BOT_IDLE)
.map(({ label, selfId, code, rate }) => {
return `${label || selfId}:${code ? '无法连接' : `工作中(${rate}/min)`}`;
});
output.push('==========');
output.push(`活跃用户数量:${activeUsers}`, `活跃群数量:${activeGroups}`, `启动时间:${new Date(startTime).toLocaleString('zh-CN', { hour12: false })}`, `CPU 使用率:${(cpu.app * 100).toFixed()}% / ${(cpu.total * 100).toFixed()}%`, `内存使用率:${(memory.app * 100).toFixed()}% / ${(memory.total * 100).toFixed()}%`);
return output.join('\n');
},
};
exports.name = 'status';
function apply(ctx, config = {}) {
const app = ctx.app;
const { refresh = koishi_utils_1.Time.minute } = config;
const { refresh, output } = { ...defaultConfig, ...config };
app.on('before-command', ({ session }) => {

@@ -106,13 +119,3 @@ session.$user['lastCall'] = new Date();

.action(async () => {
const status = await getStatus();
const { bots, cpu, memory, startTime, activeUsers, activeGroups } = status;
const output = bots
.filter(bot => bot.code !== koishi_core_1.BotStatusCode.BOT_IDLE)
.map(({ label, selfId, code, rate }) => {
return `${label || selfId}:${code ? '无法连接' : `工作中(${rate}/min)`}`;
});
output.push('==========');
output.push(`活跃用户数量:${activeUsers}`, `活跃群数量:${activeGroups}`, `启动时间:${new Date(startTime).toLocaleString('zh-CN', { hour12: false })}`, `CPU 使用率:${(cpu.app * 100).toFixed()}% / ${(cpu.total * 100).toFixed()}%`, `内存使用率:${(memory.app * 100).toFixed()}% / ${(memory.total * 100).toFixed()}%`);
ctx.emit('status', status, output);
return output.join('\n');
return output(await getStatus());
});

@@ -119,0 +122,0 @@ async function _getStatus(extend) {

{
"name": "koishi-plugin-status",
"description": "Show Status of Koishi",
"version": "2.0.0-beta.16",
"version": "2.0.0-beta.17",
"main": "dist/index.js",

@@ -35,10 +35,10 @@ "typings": "dist/index.d.ts",

"peerDependencies": {
"koishi-core": "^2.3.1",
"koishi-core": "^2.3.2",
"koishi-utils": "^3.1.5"
},
"devDependencies": {
"koishi-plugin-mongo": "^1.0.4",
"koishi-plugin-mysql": "^2.0.1",
"koishi-plugin-mongo": "^1.1.0",
"koishi-plugin-mysql": "^2.0.2",
"koishi-test-utils": "^5.0.2"
}
}
# [koishi-plugin-status](https://koishi.js.org/plugins/other/status)
[![npm](https://img.shields.io/npm/v/koishi-plugin-status?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-status)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc