koishi-plugin-node-async-bot-all 2.31.0 → 3.0.1

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,33 +1,12 @@
1
- import { Context, Session } from 'koishi';
1
+ import { Context, Session } from "koishi";
2
2
  import { Installer } from "@koishijs/plugin-market";
3
- import Puppeteer from 'koishi-plugin-puppeteer';
4
- declare module 'koishi' {
3
+ import Puppeteer from "koishi-plugin-puppeteer";
4
+ declare module "koishi" {
5
5
  interface Context {
6
6
  installer: Installer;
7
7
  puppeteer: Puppeteer;
8
8
  }
9
9
  }
10
- export interface APINews {
11
- appnews: AppNews;
12
- }
13
- interface AppNews {
14
- appid: number;
15
- newsitems: NewsItem[];
16
- count: number;
17
- }
18
- interface NewsItem {
19
- gid: string;
20
- title: string;
21
- url: string;
22
- is_external_url: boolean;
23
- author: string;
24
- contents: string;
25
- feedlabel: string;
26
- date: number;
27
- feedname: string;
28
- feed_type: number;
29
- appid: number;
30
- }
31
10
  interface Heartbeat {
32
11
  status: 0 | 1;
33
12
  time: string;
@@ -44,17 +23,27 @@ export interface MonitorStatusResponse {
44
23
  heartbeatList: HeartbeatList;
45
24
  uptimeList: UptimeList;
46
25
  }
47
- export declare function getServer(ctx: Context, session: Session): Promise<number>;
48
- export declare function getStatus(ctx: Context, session: Session): Promise<Object>;
49
- export declare function getRandom(ctx: Context, session: Session, min: number, max: number): Promise<Object>;
50
- export declare function getInfo(ctx: Context, session: Session): Promise<Object>;
51
- export declare function getRandomWord(ctx: Context, session: Session): Promise<Object>;
52
- export declare function getBlueArchive(ctx: Context, session: Session): Promise<Number>;
53
- export declare function centerServerTest(ctx: Context, session: Session): Promise<number>;
54
- export declare function getCat(ctx: Context, session: Session): Promise<Number>;
55
- export declare function getNewsMsg(ctx: Context, type: number): Promise<{
56
- success: boolean;
57
- data?: Buffer;
58
- msg: string;
59
- }>;
26
+ export declare class CommandHandler {
27
+ private ctx;
28
+ private session;
29
+ private log;
30
+ private time;
31
+ private readonly isQQ;
32
+ constructor(ctx: Context, session: Session, loggerName: string);
33
+ private sendMsg;
34
+ private sendFailed;
35
+ server(): Promise<number>;
36
+ status(): Promise<object>;
37
+ random(min: number, max: number): Promise<object>;
38
+ info(): Promise<object>;
39
+ randomWord(): Promise<object>;
40
+ blueArchive(): Promise<number>;
41
+ centerServerTest(): Promise<number>;
42
+ cat(): Promise<number>;
43
+ static getNewsMsg(ctx: Context, type: number): Promise<{
44
+ success: boolean;
45
+ data?: Buffer;
46
+ msg: string;
47
+ }[]>;
48
+ }
60
49
  export {};
@@ -0,0 +1,38 @@
1
+ import { Schema } from "koishi";
2
+ export declare const name = "node-async-bot-all";
3
+ export declare const usage = "\u8FD9\u662F\u4E00\u4E2A\u79C1\u6709\u63D2\u4EF6\u3002";
4
+ export interface ConfigCxV3 {
5
+ id: string;
6
+ server: Array<ConfigV3Server>;
7
+ }
8
+ interface ConfigV3Server {
9
+ api: string;
10
+ note: string;
11
+ type: "mc" | "a2s" | null | undefined;
12
+ }
13
+ interface ConfigV2SteamNews {
14
+ name: string;
15
+ appUrl: string;
16
+ }
17
+ export interface ConfigType {
18
+ cxV3: Array<ConfigCxV3>;
19
+ rwAPI: string;
20
+ htmlTimeout: number;
21
+ timeout: number;
22
+ baAPI: string[];
23
+ newsAPI: Array<ConfigV2SteamNews>;
24
+ catAPI: string;
25
+ steamNews: string[];
26
+ specialMsg: string[];
27
+ reactionId: number[];
28
+ }
29
+ export interface botDataTables {
30
+ id: string;
31
+ data: string;
32
+ }
33
+ export interface botDataType {
34
+ uptime: string;
35
+ version: string;
36
+ }
37
+ export declare const Config: Schema<ConfigType>;
38
+ export {};
package/lib/fun.d.ts CHANGED
@@ -1,14 +1,27 @@
1
- import { Context } from "koishi";
2
- import { APINews } from "./commands.ts";
3
- import { JavaStatusResponse } from 'minecraft-server-util';
4
- export type HttpResponse<T> = {
1
+ import { Context, HTTP, Logger } from "koishi";
2
+ import { JavaStatusResponse } from "minecraft-server-util";
3
+ export type HttpResponse<T, E> = {
5
4
  success: true;
6
5
  data: T;
7
6
  } | {
8
7
  success: false;
9
- error: any;
10
- code?: number;
11
- isJson: boolean;
8
+ error: string;
9
+ code: number;
10
+ isObj: false;
11
+ isError: false;
12
+ } | {
13
+ success: false;
14
+ error: E;
15
+ code: number;
16
+ isObj: true;
17
+ isError: false;
18
+ } | {
19
+ success: false;
20
+ error: {
21
+ name: string;
22
+ message: string;
23
+ };
24
+ isError: true;
12
25
  };
13
26
  export type serverInfo = {
14
27
  players: string;
@@ -37,13 +50,19 @@ export declare function readInfo(ctx: Context): Promise<{
37
50
  nodeVersion: string;
38
51
  } | string>;
39
52
  export declare function formatTimestampDiff(start: number, end: number): string;
40
- export declare function getMsgCount(ctx: Context): Promise<Object>;
53
+ export declare function getMsgCount(ctx: Context): Promise<{
54
+ receive: number;
55
+ send: number;
56
+ }>;
41
57
  export declare function random(type: number | undefined, data: number | number[], data2?: number): number;
42
- export declare function request<T = any>(url: string, options?: RequestInit, timeout?: number, log?: any): Promise<HttpResponse<T>>;
43
- export declare function queryA2S(host: string, log: any): Promise<serverInfo>;
44
- export declare function readNewsFile(info: APINews, log: any): Promise<string[]>;
45
- export declare function translateAPI(log: any, text: string): Promise<string>;
46
- export declare function slpInfo(log: any, host: string, port: number, timeout?: number): Promise<{
58
+ export declare function request<T = any, E = any>(url: string, ctx: Context, options?: HTTP.RequestConfig, logger?: Logger): Promise<HttpResponse<T, E>>;
59
+ export declare function queryA2S(host: string, log: Logger): Promise<serverInfo>;
60
+ export declare function parseNewsRssToHtml(rss: string, log: Logger, count?: number): Promise<{
61
+ data?: string;
62
+ guid?: string;
63
+ error?: any;
64
+ }>;
65
+ export declare function slpInfo(log: Logger, host: string, port: number, timeout?: number): Promise<{
47
66
  success: true;
48
67
  data: JavaStatusResponse;
49
68
  } | {
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Context, Schema } from 'koishi';
1
+ import { Context, Command } from "koishi";
2
+ import { botDataTables, botDataType } from "./config.ts";
2
3
  export declare const inject: string[];
3
- declare module 'koishi' {
4
+ declare module "koishi" {
4
5
  interface Tables {
5
6
  botData: botDataTables;
6
7
  }
@@ -11,33 +12,25 @@ declare module 'koishi' {
11
12
  cron: (expression: string, callback: () => void) => void;
12
13
  }
13
14
  }
14
- interface botDataTables {
15
- id: string;
16
- data: string;
17
- }
18
- export declare const name = "node-async-bot-all";
19
- export declare const usage = "\u8FD9\u662F\u4E00\u4E2A\u79C1\u6709\u63D2\u4EF6\u3002";
20
- export interface ConfigCxV3 {
21
- id: string;
22
- server: Array<ConfigV3Server>;
23
- }
24
- interface ConfigV3Server {
25
- api: string;
26
- note: string;
27
- type: "mc" | "a2s" | null | undefined;
28
- }
29
- export interface Config {
30
- cxV3: Array<ConfigCxV3>;
31
- rwAPI: string;
32
- htmlTimeout: number;
33
- timeout: number;
34
- baAPI: string[];
35
- newsAPI: string;
36
- catAPI: string;
37
- slNews: string[];
38
- specialMsg: string[];
39
- reactionId: number[];
40
- }
41
- export declare const Config: Schema<Config>;
15
+ export { Config, name, usage } from "./config.ts";
42
16
  export declare function apply(ctx: Context): void;
43
- export {};
17
+ export declare class NodeAsyncBot {
18
+ private _ctx;
19
+ private _botData;
20
+ private _na;
21
+ private _registeredNews;
22
+ private _registeredCommand;
23
+ get ctx(): Context;
24
+ private set ctx(value);
25
+ get botData(): botDataType;
26
+ private set botData(value);
27
+ get na(): Command;
28
+ private set na(value);
29
+ init(ct: Context): Promise<void>;
30
+ private startReaction;
31
+ private endReaction;
32
+ private endReactionFailed;
33
+ private execCommand;
34
+ registerNews(): Promise<void>;
35
+ registerCommand(): Promise<void>;
36
+ }