koishi-plugin-node-async-bot-all 2.1.0 → 2.2.0

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/lib/commands.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Context } from 'koishi';
2
- export declare function getServer(ctx: Context, session: any): Promise<object>;
3
- export declare function getStatus(ctx: Context, session: any): Promise<object>;
4
- export declare function getRandom(ctx: Context, session: any, min: number, max: number): Promise<object>;
5
- export declare function getInfo(ctx: Context, session: any): Promise<object>;
6
- export declare function getRW(ctx: Context, session: any): Promise<object>;
1
+ import { Context, Session } from 'koishi';
2
+ export declare function getServer(ctx: Context, session: Session): Promise<Object>;
3
+ export declare function getStatus(ctx: Context, session: Session): Promise<Object>;
4
+ export declare function getRandom(ctx: Context, session: Session, min: number, max: number): Promise<Object>;
5
+ export declare function getInfo(ctx: Context, session: Session): Promise<Object>;
6
+ export declare function getRW(ctx: Context, session: Session): Promise<Object>;
package/lib/fun.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import { Context } from "koishi";
2
- export declare function getSystemUsage(): Promise<object>;
1
+ import { Context, FlatPick } from "koishi";
2
+ import Analytics from "@koishijs/plugin-analytics";
3
+ export declare function getSystemUsage(): Promise<Object>;
3
4
  export declare function getHongKongTime(): string;
4
5
  export declare function fetchWithTimeout(url: string, options: {}, timeout: number, log: any): Promise<Response>;
5
6
  export declare function readInfoFile(ctx: Context): Promise<string>;
6
7
  export declare function formatTimestampDiff(start: number, end: number): string;
8
+ export declare function getMsgCount(array: FlatPick<Analytics.Message, "type" | "count">[]): Object;
package/lib/index.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { Context, Schema } from 'koishi';
2
+ export declare const inject: string[];
3
+ declare module 'koishi' {
4
+ interface Tables {
5
+ botData: botDataTables;
6
+ }
7
+ }
8
+ interface botDataTables {
9
+ id: string;
10
+ data: string;
11
+ }
12
+ export declare const name = "node-async-bot-all";
13
+ export declare const usage = "\u8FD9\u662F\u4E00\u4E2A\u79C1\u6709\u63D2\u4EF6\u3002";
14
+ export interface Config {
15
+ cxAPI: string;
16
+ rwAPI: string;
17
+ timeout: number;
18
+ }
19
+ export declare const Config: Schema<Config>;
20
+ export declare function apply(ctx: Context): void;
21
+ export {};
package/lib/index.js CHANGED
@@ -33,7 +33,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
33
33
  // src/locales/zh-CN.yml
34
34
  var require_zh_CN = __commonJS({
35
35
  "src/locales/zh-CN.yml"(exports2, module2) {
36
- module2.exports = { commands: { cx: { description: "查询服务器当前人数。", messages: { msg: "{time}\n【服务器当前人数】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 协议版本:{protocol}\n进服指南请在群公告中查看。", msgNoPlayer: "{time}\n【服务器当前人数】\n➣ {version}:{players}\n➣ 协议版本:{protocol}\n进服指南请在群公告中查看。", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}\n请稍后重试。", timeout: "请求超时。", timeout2: "响应超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", error: "执行错误。", unknown: "未知错误。", host: "没有到主机的路由。" } }, status: { description: "查询机器人状态。", messages: { msg: "{time}\n系统名称:{name}\nCPU使用率:{cpu}\n内存使用率:{memory}\n运行时间:{online}", failed: "{time}\n状态获取失败。" } }, random: { description: "随机数生成器。", usage: "缺少参数时默认生成 0-10000 的随机数。\n使用示例:", examples: "random 1 128 生成1到128范围的随机数", messages: { msg: "{time}\n生成的随机数:{data}" } }, info: { description: "查询机器人信息。", messages: { msg: "{data}", failed: "{time}\n读取信息失败。" } }, rw: { description: "随机名言名句。", messages: { msg: "{time}\n{data}", failed1: "{time}\n获取失败(1)。", failed2: "{time}\n获取失败(2)。" } } } };
36
+ module2.exports = { commands: { cx: { description: "查询服务器当前人数。", messages: { msg: "{time}\n【服务器当前人数】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 协议版本:{protocol}\n进服指南请在群公告中查看。", msgNoPlayer: "{time}\n【服务器当前人数】\n➣ {version}:{players}\n➣ 协议版本:{protocol}\n进服指南请在群公告中查看。", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}\n请稍后重试。", timeout: "请求超时。", timeout2: "响应超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", error: "执行错误。", unknown: "未知错误。", host: "没有到主机的路由。" } }, status: { description: "查询机器人状态。", messages: { msg: "{time}\n--- 系统状态 ---\n系统名称:{name}\nCPU使用率:{cpu}\n内存使用率:{memory}\n--- 机器人状态 ---\n昨日收/发消息数量:{msgCount}\n机器人版本:{version}\n运行时间:{online}", failed: "{time}\n状态获取失败。" } }, random: { description: "随机数生成器。", usage: "缺少参数时默认生成 0-10000 的随机数。\n使用示例:", examples: "random 1 128 生成1到128范围的随机数", messages: { msg: "{time}\n生成的随机数:{data}" } }, info: { description: "查询机器人信息。", messages: { msg: "{data}", failed: "{time}\n读取信息失败。" } }, rw: { description: "随机名言名句。", messages: { msg: "{time}\n{data}", failed1: "{time}\n获取失败(1)。", failed2: "{time}\n获取失败(2)。" } } } };
37
37
  }
38
38
  });
39
39
 
@@ -47,6 +47,9 @@ __export(src_exports, {
47
47
  usage: () => usage
48
48
  });
49
49
  module.exports = __toCommonJS(src_exports);
50
+ var import_koishi2 = require("koishi");
51
+
52
+ // src/commands.ts
50
53
  var import_koishi = require("koishi");
51
54
 
52
55
  // src/fun.ts
@@ -157,6 +160,19 @@ function formatTimestampDiff(start, end) {
157
160
  return `${hours} 时 ${minutes} 分 ${seconds} 秒`;
158
161
  }
159
162
  __name(formatTimestampDiff, "formatTimestampDiff");
163
+ function getMsgCount(array) {
164
+ let receive = 0;
165
+ let send = 0;
166
+ array.forEach((item) => {
167
+ if (item.type == "receive") {
168
+ receive = receive + item.count;
169
+ } else {
170
+ send = send + item.count;
171
+ }
172
+ });
173
+ return { "receive": receive, "send": send };
174
+ }
175
+ __name(getMsgCount, "getMsgCount");
160
176
 
161
177
  // src/commands.ts
162
178
  async function getServer(ctx, session) {
@@ -263,7 +279,7 @@ async function getStatus(ctx, session) {
263
279
  "success": 1
264
280
  };
265
281
  } else {
266
- log.info((await ctx.database.get("botData", "uptime"))[0].data);
282
+ const msgCount = getMsgCount(await ctx.database.get("analytics.message", { date: import_koishi.Time.getDateNumber() - 1 }, ["type", "count"]));
267
283
  msg = {
268
284
  "time": time,
269
285
  "name": vMsg["name"],
@@ -271,8 +287,10 @@ async function getStatus(ctx, session) {
271
287
  "memory": vMsg["memory"],
272
288
  "online": formatTimestampDiff(
273
289
  Number((await ctx.database.get("botData", "uptime"))[0].data),
274
- session.event.timestamp.toString().substring(0, 10)
290
+ Number(session.event.timestamp.toString().substring(0, 10))
275
291
  ),
292
+ "msgCount": `${msgCount["receive"]}/${msgCount["send"]}`,
293
+ "version": (await ctx.database.get("botData", "version"))[0].data,
276
294
  "success": 0
277
295
  };
278
296
  }
@@ -372,21 +390,21 @@ async function getRW(ctx, session) {
372
390
  __name(getRW, "getRW");
373
391
 
374
392
  // package.json
375
- var version = "2.1.0";
393
+ var version = "2.2.0";
376
394
 
377
395
  // src/index.ts
378
- var inject = ["silk", "database"];
396
+ var inject = ["database"];
379
397
  var name = "node-async-bot-all";
380
398
  var usage = "这是一个私有插件。";
381
- var Config = import_koishi.Schema.intersect([
382
- import_koishi.Schema.object({
383
- timeout: import_koishi.Schema.number().default(8e3).description("超时时间(毫秒)")
399
+ var Config = import_koishi2.Schema.intersect([
400
+ import_koishi2.Schema.object({
401
+ timeout: import_koishi2.Schema.number().default(8e3).description("超时时间(毫秒)")
384
402
  }).description("基础"),
385
- import_koishi.Schema.object({
386
- cxAPI: import_koishi.Schema.string().default("https://api.tasaed.top/get/minecraftServer/").description("查询 API")
403
+ import_koishi2.Schema.object({
404
+ cxAPI: import_koishi2.Schema.string().default("https://api.tasaed.top/get/minecraftServer/").description("查询 API")
387
405
  }).description("查询"),
388
- import_koishi.Schema.object({
389
- rwAPI: import_koishi.Schema.string().default("https://api.tasaed.top/rw/").description("随机文本 API")
406
+ import_koishi2.Schema.object({
407
+ rwAPI: import_koishi2.Schema.string().default("https://api.tasaed.top/rw/").description("随机文本 API")
390
408
  }).description("随机文本")
391
409
  ]).description("基础设置");
392
410
  function apply(ctx) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-node-async-bot-all",
3
3
  "description": "NodeAsync Bot插件(自用)",
4
- "version": "2.1.0",
4
+ "version": "2.2.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [
@@ -33,6 +33,6 @@
33
33
  "peerDependencies": {
34
34
  "@koishijs/plugin-help": "^2.4.5",
35
35
  "koishi": "^4.18.7",
36
- "koishi-plugin-silk": "^2.0.1"
36
+ "@koishijs/plugin-database-sqlite": "^4.6.0"
37
37
  }
38
38
  }