koishi-plugin-oni-sync-bot 0.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/config/index.d.ts +15 -0
- package/lib/index.d.ts +26 -0
- package/lib/sync/imgSync.d.ts +30 -0
- package/lib/sync/moduleSync.d.ts +21 -0
- package/lib/sync/pageSync.d.ts +30 -0
- package/lib/utils/login.d.ts +8 -0
- package/lib/utils/tools.d.ts +18 -0
- package/package.json +31 -0
- package/readme.md +5 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Config } from "../index";
|
|
2
|
+
export interface ISiteConfig {
|
|
3
|
+
name: string;
|
|
4
|
+
api: string;
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
uakey?: string;
|
|
8
|
+
userAgent: string;
|
|
9
|
+
}
|
|
10
|
+
interface ISitesConfig {
|
|
11
|
+
gg: ISiteConfig;
|
|
12
|
+
huiji: ISiteConfig;
|
|
13
|
+
}
|
|
14
|
+
export declare function getSitesConfig(config: Config): ISitesConfig;
|
|
15
|
+
export {};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Context, Schema } from "koishi";
|
|
2
|
+
export declare const name = "oni-sync-bot";
|
|
3
|
+
export declare const inject: string[];
|
|
4
|
+
declare module "koishi" {
|
|
5
|
+
interface Tables {
|
|
6
|
+
wikipages: WikiPages;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export interface WikiPages {
|
|
10
|
+
id: number;
|
|
11
|
+
title: string;
|
|
12
|
+
pinyin_full: string;
|
|
13
|
+
pinyin_first: string;
|
|
14
|
+
}
|
|
15
|
+
export interface Config {
|
|
16
|
+
ggUsername: string;
|
|
17
|
+
ggPassword: string;
|
|
18
|
+
huijiUsername: string;
|
|
19
|
+
huijiPassword: string;
|
|
20
|
+
huijiUAKey: string;
|
|
21
|
+
domain: string;
|
|
22
|
+
main_site: string;
|
|
23
|
+
mirror_site: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const Config: Schema<Config>;
|
|
26
|
+
export declare function apply(ctx: Context, config: Config): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Mwn } from "mwn";
|
|
2
|
+
import { Config } from "../index";
|
|
3
|
+
export declare const CONFIG: {
|
|
4
|
+
IGNORED_IMAGES: any[];
|
|
5
|
+
SYNC_INTERVAL_SUCCESS: number;
|
|
6
|
+
SYNC_INTERVAL_FAILED: number;
|
|
7
|
+
UPLOAD_COMMENT: string;
|
|
8
|
+
UPLOAD_TEXT: string;
|
|
9
|
+
};
|
|
10
|
+
interface ImageInfo {
|
|
11
|
+
url: string;
|
|
12
|
+
sha1: string;
|
|
13
|
+
size?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 获取图片的原始URL和SHA1
|
|
17
|
+
*/
|
|
18
|
+
declare function getImageInfo(site: Mwn, fileName: string): Promise<ImageInfo | null>;
|
|
19
|
+
/**
|
|
20
|
+
* 同步单个图片
|
|
21
|
+
*/
|
|
22
|
+
declare function syncSingleImage(sourceBot: Mwn, targetBot: Mwn, fileName: string, config: Config): Promise<{
|
|
23
|
+
success: boolean;
|
|
24
|
+
reason?: string;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* 批量同步所有图片(带失败重试)
|
|
28
|
+
*/
|
|
29
|
+
declare function syncAllImages(sourceBot: Mwn, targetBot: Mwn, config: Config): Promise<void>;
|
|
30
|
+
export { syncSingleImage, syncAllImages, getImageInfo };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Mwn } from "mwn";
|
|
2
|
+
/**
|
|
3
|
+
* 同步单个模块
|
|
4
|
+
* @param oldSite 原站点
|
|
5
|
+
* @param newSite 新站点
|
|
6
|
+
* @param moduleTitle 模块标题
|
|
7
|
+
* @param user 触发同步的用户
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
declare function syncSingleModule(oldSite: Mwn, newSite: Mwn, moduleTitle: string, user?: string): Promise<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
reason?: string;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* 批量同步所有模块
|
|
16
|
+
* @param oldSite 原站点
|
|
17
|
+
* @param newSite 新站点
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
declare function syncModules(oldSite: Mwn, newSite: Mwn): Promise<void>;
|
|
21
|
+
export { syncSingleModule, syncModules };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Mwn } from "mwn";
|
|
2
|
+
import { Config } from "../index";
|
|
3
|
+
/**
|
|
4
|
+
* 单页面同步
|
|
5
|
+
* @param oldSite 源站点机器人实例
|
|
6
|
+
* @param newSite 目标站点机器人实例
|
|
7
|
+
* @param pageTitle 同步的标题
|
|
8
|
+
* @param user 触发更改的用户
|
|
9
|
+
* @returns success: boolean;reason: string;
|
|
10
|
+
}
|
|
11
|
+
*/
|
|
12
|
+
declare function syncSinglePage(oldSite: Mwn, newSite: Mwn, pageTitle: string, user: string): Promise<{
|
|
13
|
+
success: boolean;
|
|
14
|
+
reason: string;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* 同步所有页面
|
|
18
|
+
* @param oldSite 源站点机器人实例
|
|
19
|
+
* @param newSite 目标站点机器人实例
|
|
20
|
+
* @returns null
|
|
21
|
+
*/
|
|
22
|
+
declare function syncPages(oldSite: Mwn, newSite: Mwn): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* 增量更新
|
|
25
|
+
* @param oldSite 源站点机器人实例
|
|
26
|
+
* @param newSite 目标站点机器人实例
|
|
27
|
+
* @param config KOISHI用户配置的项
|
|
28
|
+
*/
|
|
29
|
+
declare function incrementalUpdate(oldSite: Mwn, newSite: Mwn, config: Config): Promise<void>;
|
|
30
|
+
export { syncSinglePage, syncPages, incrementalUpdate };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Mwn } from "mwn";
|
|
2
|
+
/**
|
|
3
|
+
* 获取并处理页面内容
|
|
4
|
+
* @param site 机器人实例
|
|
5
|
+
* @param pageTitle 页面标题
|
|
6
|
+
* @returns 处理后的页面内容(移除跨站链接 + 全局替换 Dev: 为 Module:Dev/)
|
|
7
|
+
*/
|
|
8
|
+
declare function getAndProcessPageContent(site: Mwn, pageTitle: string): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* 处理文本,生成标准化的全拼和首字母
|
|
11
|
+
* @param text 中文文本
|
|
12
|
+
* @returns {pinyin_full: string, pinyin_first: string} 处理后的拼音信息
|
|
13
|
+
*/
|
|
14
|
+
declare function generatePinyinInfo(text: string): {
|
|
15
|
+
pinyin_full: string;
|
|
16
|
+
pinyin_first: string;
|
|
17
|
+
};
|
|
18
|
+
export { getAndProcessPageContent, generatePinyinInfo };
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "koishi-plugin-oni-sync-bot",
|
|
3
|
+
"description": "缺氧Wiki站镜像点同步-测试",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"typings": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"chatbot",
|
|
14
|
+
"koishi",
|
|
15
|
+
"plugin"
|
|
16
|
+
],
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@koishijs/client": "^5.30.4"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@koishijs/plugin-console": "^5.30.4",
|
|
22
|
+
"koishi": "^4.18.7"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@types/node-fetch": "^2.6.13",
|
|
26
|
+
"koishi-plugin-cron": "^3.1.0",
|
|
27
|
+
"mwn": "^3.0.1",
|
|
28
|
+
"node-fetch": "^3.3.2",
|
|
29
|
+
"pinyin-pro": "^3.28.0"
|
|
30
|
+
}
|
|
31
|
+
}
|