koishi-plugin-oni-sync-bot 0.6.2 → 0.7.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.
@@ -0,0 +1,13 @@
1
+ import { Context, Logger } from "koishi";
2
+ declare module "@koishijs/console" {
3
+ namespace Console {
4
+ interface Services {
5
+ onilogs: DataService<Logger.Record[]>;
6
+ }
7
+ }
8
+ }
9
+ export declare class ConsoleLogProvider {
10
+ static readonly inject: string[];
11
+ constructor(ctx: Context);
12
+ }
13
+ export declare function apply(ctx: Context): void;
@@ -0,0 +1,17 @@
1
+ import { Context } from "koishi";
2
+ declare module "koishi" {
3
+ interface Tables {
4
+ wikipages: WikiPages;
5
+ }
6
+ }
7
+ export interface WikiPages {
8
+ id: number;
9
+ title: string;
10
+ pinyin_full: string;
11
+ pinyin_first: string;
12
+ }
13
+ export declare class DatabaseExtension {
14
+ static readonly inject: string[];
15
+ constructor(ctx: Context);
16
+ }
17
+ export declare function apply(ctx: Context): void;
@@ -0,0 +1,20 @@
1
+ import { Context, Schema } from "koishi";
2
+ export interface QueryCommandsConfig {
3
+ domain: string;
4
+ }
5
+ export declare class QueryCommands {
6
+ static readonly inject: string[];
7
+ config: QueryCommandsConfig;
8
+ constructor(ctx: Context, config: QueryCommandsConfig);
9
+ private registerCommands;
10
+ private getUsageMessage;
11
+ private formatResultMessage;
12
+ private findPreciseMatch;
13
+ private calculateScore;
14
+ private findFuzzyMatches;
15
+ private handleSelection;
16
+ }
17
+ export declare namespace QueryCommands {
18
+ const Config: Schema<QueryCommandsConfig>;
19
+ }
20
+ export declare function apply(ctx: Context, config: QueryCommandsConfig): void;
@@ -0,0 +1,15 @@
1
+ import { Context, Schema } from "koishi";
2
+ export interface RouteRedirectConfig {
3
+ domain: string;
4
+ main_site: string;
5
+ bwiki_site: string;
6
+ }
7
+ export declare class RouteRedirect {
8
+ static readonly inject: string[];
9
+ config: RouteRedirectConfig;
10
+ constructor(ctx: Context, config: RouteRedirectConfig);
11
+ }
12
+ export declare namespace RouteRedirect {
13
+ const Config: Schema<RouteRedirectConfig>;
14
+ }
15
+ export declare function apply(ctx: Context, config: RouteRedirectConfig): void;
@@ -0,0 +1,23 @@
1
+ import { Context, Logger, Schema } from "koishi";
2
+ export interface SyncCommandsConfig {
3
+ logsUrl: string;
4
+ ggUsername: string;
5
+ ggPassword: string;
6
+ bwikiusername: string;
7
+ bwikipassword: string;
8
+ domain: string;
9
+ main_site: string;
10
+ bwiki_site: string;
11
+ }
12
+ export declare class SyncCommands {
13
+ static readonly inject: string[];
14
+ config: SyncCommandsConfig;
15
+ log: Logger;
16
+ constructor(ctx: Context, config: SyncCommandsConfig);
17
+ private checkBotsReady;
18
+ private registerCommands;
19
+ }
20
+ export declare namespace SyncCommands {
21
+ const Config: Schema<SyncCommandsConfig>;
22
+ }
23
+ export declare function apply(ctx: Context, config: SyncCommandsConfig): void;
@@ -0,0 +1,15 @@
1
+ import { Context, Logger, Schema } from "koishi";
2
+ export interface UpdateCommandsConfig {
3
+ logsUrl: string;
4
+ }
5
+ export declare class UpdateCommands {
6
+ static readonly inject: string[];
7
+ config: UpdateCommandsConfig;
8
+ log: Logger;
9
+ constructor(ctx: Context, config: UpdateCommandsConfig);
10
+ private registerCommands;
11
+ }
12
+ export declare namespace UpdateCommands {
13
+ const Config: Schema<UpdateCommandsConfig>;
14
+ }
15
+ export declare function apply(ctx: Context, config: UpdateCommandsConfig): void;
@@ -0,0 +1,49 @@
1
+ import { Context, Service, Schema } from "koishi";
2
+ import { Mwn } from "mwn";
3
+ declare module "koishi" {
4
+ interface Context {
5
+ wikiBot: WikiBotService;
6
+ }
7
+ }
8
+ export interface ISiteConfig {
9
+ name: string;
10
+ api: string;
11
+ username: string;
12
+ password: string;
13
+ userAgent: string;
14
+ }
15
+ export declare class WikiBotService extends Service {
16
+ static readonly inject: any[];
17
+ ggbot: Mwn | null;
18
+ bwikibot: Mwn | null;
19
+ isReady: boolean;
20
+ private botConfig;
21
+ private static readonly USER_AGENT;
22
+ private static readonly MAX_RETRIES;
23
+ private static readonly RETRY_DELAY;
24
+ constructor(ctx: Context, config: WikiBotServiceConfig);
25
+ private getSitesConfig;
26
+ private delay;
27
+ private loginWithRetry;
28
+ private login;
29
+ start(): Promise<void>;
30
+ stop(): void;
31
+ relogin(): Promise<{
32
+ gg: boolean;
33
+ bwiki: boolean;
34
+ }>;
35
+ isGGBotReady(): boolean;
36
+ isBWikiBotReady(): boolean;
37
+ getGGBot(): Mwn;
38
+ getBWikiBot(): Mwn;
39
+ }
40
+ export interface WikiBotServiceConfig {
41
+ ggUsername: string;
42
+ ggPassword: string;
43
+ bwikiusername: string;
44
+ bwikipassword: string;
45
+ }
46
+ export declare namespace WikiBotService {
47
+ const Config: Schema<WikiBotServiceConfig>;
48
+ }
49
+ export declare function apply(ctx: Context, config: WikiBotServiceConfig): void;
@@ -0,0 +1,21 @@
1
+ import { Logger } from "koishi";
2
+ import { Mwn } from "mwn";
3
+ /**
4
+ * 获取并处理页面内容
5
+ * @param site 机器人实例
6
+ * @param pageTitle 页面标题
7
+ * @returns 处理后的页面内容(移除跨站链接 + 全局替换 Dev: 为 Module:Dev/)
8
+ */
9
+ declare function getAndProcessPageContent(site: Mwn, pageTitle: string): Promise<string>;
10
+ /**
11
+ * 处理文本,生成标准化的全拼和首字母
12
+ * @param text 中文文本
13
+ * @returns {pinyin_full: string, pinyin_first: string} 处理后的拼音信息
14
+ */
15
+ declare function generatePinyinInfo(text: string): {
16
+ pinyin_full: string;
17
+ pinyin_first: string;
18
+ };
19
+ declare function getErrorMessage(error: unknown): string;
20
+ declare const logger: Logger;
21
+ export { getAndProcessPageContent, generatePinyinInfo, logger, getErrorMessage };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-oni-sync-bot",
3
3
  "description": "缺氧Wiki站镜像点同步-测试",
4
- "version": "0.6.2",
4
+ "version": "0.7.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -14,6 +14,13 @@
14
14
  "koishi",
15
15
  "plugin"
16
16
  ],
17
+ "koishi": {
18
+ "description": "缺氧Wiki站镜像点同步-测试",
19
+ "service": {
20
+ "required": [],
21
+ "optional": []
22
+ }
23
+ },
17
24
  "devDependencies": {
18
25
  "@koishijs/client": "^5.30.11"
19
26
  },
@@ -1,14 +0,0 @@
1
- import { Config } from "../index";
2
- export interface ISiteConfig {
3
- name: string;
4
- api: string;
5
- username: string;
6
- password: string;
7
- userAgent: string;
8
- }
9
- interface ISitesConfig {
10
- gg: ISiteConfig;
11
- bwiki: ISiteConfig;
12
- }
13
- export declare function getSitesConfig(config: Config): ISitesConfig;
14
- export {};
@@ -1,16 +0,0 @@
1
- import { Logger, Context, Schema } from "koishi";
2
- export declare const name = "logspush";
3
- export declare const usage = "\u65E5\u5FD7\u63A8\u9001";
4
- export interface Config {
5
- logsUrl: string;
6
- }
7
- export declare const Config: Schema<Config>;
8
- declare module "@koishijs/console" {
9
- namespace Console {
10
- interface Services {
11
- onilogs: DataService<Logger.Record[]>;
12
- }
13
- }
14
- }
15
- export declare let logBuffer: Logger.Record[];
16
- export default function apply(ctx: Context, config: Config): void;
@@ -1,9 +0,0 @@
1
- import { Context, Schema } from "koishi";
2
- export interface Config {
3
- main_site: string;
4
- bwiki_site: string;
5
- }
6
- export declare const Config: Schema<Config>;
7
- export declare const name = "wikirouter";
8
- export declare const usage = "wiki\u8DEF\u7531\u91CD\u5B9A\u5411";
9
- export default function apply(ctx: Context, config: Config): void;
@@ -1,29 +0,0 @@
1
- import { Mwn } from "mwn";
2
- export declare const CONFIG: {
3
- IGNORED_IMAGES: any[];
4
- SYNC_INTERVAL_SUCCESS: number;
5
- SYNC_INTERVAL_FAILED: number;
6
- UPLOAD_COMMENT: string;
7
- UPLOAD_TEXT: string;
8
- };
9
- interface ImageInfo {
10
- url: string;
11
- sha1: string;
12
- size?: number;
13
- }
14
- /**
15
- * 获取图片的原始URL和SHA1
16
- */
17
- declare function getImageInfo(site: Mwn, fileName: string): Promise<ImageInfo | null>;
18
- /**
19
- * 同步单个图片
20
- */
21
- declare function syncSingleImage(sourceBot: Mwn, targetBot: Mwn, fileName: string): Promise<{
22
- success: boolean;
23
- reason?: string;
24
- }>;
25
- /**
26
- * 批量同步所有图片(带失败重试)
27
- */
28
- declare function syncAllImages(sourceBot: Mwn, targetBot: Mwn): Promise<void>;
29
- export { syncSingleImage, syncAllImages, getImageInfo };
@@ -1,29 +0,0 @@
1
- import { Mwn } from "mwn";
2
- /**
3
- * 单页面同步
4
- * @param oldSite 源站点机器人实例
5
- * @param newSite 目标站点机器人实例
6
- * @param pageTitle 同步的标题
7
- * @param user 触发更改的用户
8
- * @returns success: boolean;reason: string;
9
- }
10
- */
11
- declare function syncSinglePage(oldSite: Mwn, newSite: Mwn, pageTitle: string, user: string): Promise<{
12
- success: boolean;
13
- reason: string;
14
- }>;
15
- /**
16
- * 同步所有页面
17
- * @param oldSite 源站点机器人实例
18
- * @param newSite 目标站点机器人实例
19
- * @returns null
20
- */
21
- declare function syncPages(oldSite: Mwn, newSite: Mwn): Promise<void>;
22
- /**
23
- * 增量更新
24
- * @param oldSite 源站点机器人实例
25
- * @param newSite 目标站点机器人实例
26
- * @param config KOISHI用户配置的项
27
- */
28
- declare function incrementalUpdate(oldSite: Mwn, newSite: Mwn): Promise<void>;
29
- export { syncSinglePage, syncPages, incrementalUpdate };
@@ -1,8 +0,0 @@
1
- import { Context, Schema } from "koishi";
2
- export declare const name = "synctask_imgs";
3
- export declare const usage = "\u56FE\u7247\u540C\u6B65\u4EFB\u52A1";
4
- export interface Config {
5
- logsUrl: string;
6
- }
7
- export declare const Config: Schema<Config>;
8
- export default function apply(ctx: Context, config: Config): void;
@@ -1,8 +0,0 @@
1
- import { Context, Schema } from "koishi";
2
- export declare const name = "synctask";
3
- export declare const usage = "\u540C\u6B65\u4EFB\u52A1";
4
- export interface Config {
5
- logsUrl: string;
6
- }
7
- export declare const Config: Schema<Config>;
8
- export default function apply(ctx: Context, config: Config): void;
@@ -1,49 +0,0 @@
1
- import { Context, Schema } from "koishi";
2
- import { DataService } from "@koishijs/plugin-console";
3
- export declare const name = "synctask_modules";
4
- export declare const usage = "\u540C\u6B65\u6A21\u5757";
5
- export declare const inject: string[];
6
- interface IModuleData {
7
- pageid: number;
8
- pageTitle: string;
9
- user: string;
10
- lastEditTime: Date;
11
- syncStatus: boolean;
12
- }
13
- export interface Config {
14
- logsUrl: string;
15
- syncCron?: string;
16
- concurrency?: number;
17
- requestDelay?: number;
18
- }
19
- declare module "@koishijs/plugin-console" {
20
- namespace Console {
21
- interface Services {
22
- moduleManager: ModuleManagerService;
23
- }
24
- }
25
- interface Events {
26
- "module-sync/update"(payload: {
27
- pageid: number;
28
- operator?: string;
29
- }): Promise<{
30
- success: boolean;
31
- }>;
32
- "module-sync/trigger"(): Promise<{
33
- success: boolean;
34
- message: string;
35
- }>;
36
- }
37
- }
38
- declare module "koishi" {
39
- interface Tables {
40
- moduleinfo: IModuleData;
41
- }
42
- }
43
- declare class ModuleManagerService extends DataService<IModuleData[]> {
44
- constructor(ctx: Context);
45
- get(): Promise<import("minato").FlatPick<IModuleData, any>[]>;
46
- }
47
- export declare const Config: Schema<Config>;
48
- export default function apply(ctx: Context, config: Config): void;
49
- export {};
@@ -1,8 +0,0 @@
1
- import { Context, Schema } from "koishi";
2
- export declare const name = "synctask_pages";
3
- export declare const usage = "\u9875\u9762\u540C\u6B65\u4EFB\u52A1";
4
- export interface Config {
5
- logsUrl: string;
6
- }
7
- export declare const Config: Schema<Config>;
8
- export default function apply(ctx: Context, config: Config): void;
@@ -1,8 +0,0 @@
1
- import { Context, Schema } from "koishi";
2
- export declare const name = "synctask";
3
- export declare const usage = "\u5B9A\u65F6\u540C\u6B65\u4EFB\u52A1";
4
- export interface Config {
5
- logsUrl: string;
6
- }
7
- export declare const Config: Schema<Config>;
8
- export default function apply(ctx: Context, config: Config): void;
@@ -1,8 +0,0 @@
1
- import { Mwn } from "mwn";
2
- import { ISiteConfig } from "../config";
3
- /**
4
- * 登录机器人
5
- * @param siteConfig 站点配置
6
- * @returns 机器人实例
7
- */
8
- export declare function login(siteConfig: ISiteConfig): Promise<Mwn>;
@@ -1,19 +0,0 @@
1
- import { Context, Schema } from "koishi";
2
- export declare const name = "querywiki";
3
- export declare const usage = "\u67E5\u8BE2Wiki";
4
- export interface Config {
5
- domain: string;
6
- }
7
- export declare const Config: Schema<Config>;
8
- declare module "koishi" {
9
- interface Tables {
10
- wikipages: WikiPages;
11
- }
12
- }
13
- export interface WikiPages {
14
- id: number;
15
- title: string;
16
- pinyin_full: string;
17
- pinyin_first: string;
18
- }
19
- export default function queryWiki(ctx: Context, config: Config): void;
@@ -1,25 +0,0 @@
1
- import { Mwn } from "mwn";
2
- import { Config } from "..";
3
- import { Context } from "koishi";
4
- export declare const name = "wikicore";
5
- export declare const usage = "wikicore";
6
- export default function apply(ctx: Context, config: Config): void;
7
- /**
8
- * 登录机器人
9
- * @param siteConfig 站点配置
10
- * @returns 机器人实例
11
- */
12
- export declare function login(siteConfig: ISiteConfig): Promise<Mwn>;
13
- export interface ISiteConfig {
14
- name: string;
15
- api: string;
16
- username: string;
17
- password: string;
18
- userAgent: string;
19
- }
20
- interface ISitesConfig {
21
- gg: ISiteConfig;
22
- bwiki: ISiteConfig;
23
- }
24
- export declare function getSitesConfig(config: Config): ISitesConfig;
25
- export {};