koishi-plugin-oni-wiki-qq 0.3.4 → 0.4.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/index.d.ts +12 -6
- package/lib/index.js +38 -40
- package/package.json +1 -4
package/lib/index.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { Context, Schema } from "koishi";
|
|
2
2
|
export declare const name = "oni-wiki-qq";
|
|
3
|
-
export declare const usage = "\n - 0.3.4 \u6DFB\u52A0\u706B\u7BAD\u8BA1\u7B97\u5668\u5730\u5740\n - 0.3.3 \u6240\u6709\u7F51\u5740\u5904\u7406\n - 0.3.0 \u79FB\u9664\u8017\u5185\u5B58\u7684\u622A\u56FE\u90E8\u5206,\u4F7F\u7528\u955C\u50CF\u7AD9\u70B9\u7F51\u9875\n - 0.2.0 \u5C1D\u8BD5\u6DFB\u52A0 MWN \u5E93\n";
|
|
3
|
+
export declare const usage = "\n - 0.4.0 \u79FB\u9664MWN.\u5C06\u67E5\u8BE2\u5904\u7406\u6539\u81F3\u67E5\u8BE2\u6570\u636E\u5E93\n - 0.3.4 \u6DFB\u52A0\u706B\u7BAD\u8BA1\u7B97\u5668\u5730\u5740\n - 0.3.3 \u6240\u6709\u7F51\u5740\u5904\u7406\n - 0.3.0 \u79FB\u9664\u8017\u5185\u5B58\u7684\u622A\u56FE\u90E8\u5206,\u4F7F\u7528\u955C\u50CF\u7AD9\u70B9\u7F51\u9875\n - 0.2.0 \u5C1D\u8BD5\u6DFB\u52A0 MWN \u5E93\n";
|
|
4
|
+
export declare const inject: string[];
|
|
5
|
+
declare module "koishi" {
|
|
6
|
+
interface Tables {
|
|
7
|
+
wikipages: WikiPages;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export interface WikiPages {
|
|
11
|
+
id: number;
|
|
12
|
+
title: string;
|
|
13
|
+
}
|
|
4
14
|
export interface Config {
|
|
5
|
-
api: string;
|
|
6
|
-
originalUrl: string;
|
|
7
|
-
mirrorUrl: string;
|
|
8
15
|
docUrl: string;
|
|
9
|
-
userName: string;
|
|
10
|
-
password: string;
|
|
11
16
|
Rocket_Calculator: string;
|
|
17
|
+
SESSDATA: string;
|
|
12
18
|
}
|
|
13
19
|
export declare const Config: Schema<Config>;
|
|
14
20
|
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/index.js
CHANGED
|
@@ -22,72 +22,69 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
Config: () => Config,
|
|
24
24
|
apply: () => apply,
|
|
25
|
+
inject: () => inject,
|
|
25
26
|
name: () => name,
|
|
26
27
|
usage: () => usage
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(src_exports);
|
|
29
30
|
var import_koishi = require("koishi");
|
|
30
|
-
var import_mwn = require("mwn");
|
|
31
31
|
var name = "oni-wiki-qq";
|
|
32
32
|
var usage = `
|
|
33
|
+
- 0.4.0 移除MWN.将查询处理改至查询数据库
|
|
33
34
|
- 0.3.4 添加火箭计算器地址
|
|
34
35
|
- 0.3.3 所有网址处理
|
|
35
36
|
- 0.3.0 移除耗内存的截图部分,使用镜像站点网页
|
|
36
37
|
- 0.2.0 尝试添加 MWN 库
|
|
37
38
|
`;
|
|
39
|
+
var inject = ["database"];
|
|
38
40
|
var Config = import_koishi.Schema.object({
|
|
39
|
-
api: import_koishi.Schema.string().default("https://oxygennotincluded.wiki.gg/zh/api.php").description("api地址"),
|
|
40
|
-
originalUrl: import_koishi.Schema.string().default("https://oxygennotincluded.wiki.gg/zh/wiki/").description("原站点网址"),
|
|
41
|
-
mirrorUrl: import_koishi.Schema.string().default("https://klei.vip/oni/usiz6d/").description("镜像站点网址"),
|
|
42
41
|
docUrl: import_koishi.Schema.string().default("klei.vip/oni/926f8b").description("大叔的文档地址"),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Rocket_Calculator: import_koishi.Schema.string().description("火箭计算器地址").default("https://klei.vip/oni/t93o56")
|
|
42
|
+
Rocket_Calculator: import_koishi.Schema.string().description("火箭计算器地址").default("https://klei.vip/oni/t93o56"),
|
|
43
|
+
SESSDATA: import_koishi.Schema.string().description("SESSDATA")
|
|
46
44
|
});
|
|
47
45
|
function apply(ctx, config) {
|
|
48
46
|
const logger = ctx.logger;
|
|
47
|
+
ctx.model.extend("wikipages", {
|
|
48
|
+
id: "integer",
|
|
49
|
+
title: "string"
|
|
50
|
+
});
|
|
49
51
|
ctx.command("x <itemName>", "查询缺氧中文wiki").alias("/查wiki").action(async ({ session }, itemName = "电解器") => {
|
|
50
52
|
session.send(`您查询的「${itemName}」进行中,请稍等...`);
|
|
51
|
-
const res = await
|
|
52
|
-
|
|
53
|
+
const res = await ctx.database.get("wikipages", {
|
|
54
|
+
title: [`${itemName}`]
|
|
55
|
+
});
|
|
56
|
+
logger.info(res);
|
|
57
|
+
if (res.length == 0) {
|
|
53
58
|
return `在Wiki里没找到或API查询超时,如有需要,请按照游戏内名称重新发起查询....`;
|
|
54
59
|
}
|
|
55
60
|
return `请点击链接前往站点查看:
|
|
56
|
-
原站点:
|
|
57
|
-
|
|
58
|
-
"http://oni.wiki/"
|
|
61
|
+
原站点: http://oni.wiki/${encodeURI(
|
|
62
|
+
itemName
|
|
59
63
|
)}
|
|
60
|
-
镜像站:
|
|
64
|
+
镜像站: https://klei.vip/oni/usiz6d/${encodeURI(itemName)}`;
|
|
61
65
|
});
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
assert: "user"
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
return await bot.request({
|
|
73
|
-
action: "opensearch",
|
|
74
|
-
search: itemName,
|
|
75
|
-
namespace: "*",
|
|
76
|
-
limit: 3,
|
|
77
|
-
redirects: "return",
|
|
78
|
-
format: "json"
|
|
79
|
-
}).then(async (res) => {
|
|
80
|
-
logger.info(res);
|
|
81
|
-
if (res[1][0] == itemName) {
|
|
82
|
-
return res[3][0];
|
|
83
|
-
} else {
|
|
84
|
-
return "";
|
|
66
|
+
ctx.command("update", "更新本地页面缓存", { authority: 2 }).action(async () => {
|
|
67
|
+
const url = `https://wiki.biligame.com/oni/api.php?action=query&list=allpages&aplimit=5000&format=json`;
|
|
68
|
+
return await ctx.http.get(url, {
|
|
69
|
+
headers: {
|
|
70
|
+
"Content-Type": "application/json",
|
|
71
|
+
"user-agent": "Charles'queryBot",
|
|
72
|
+
Cookie: `SESSDATA=${config.SESSDATA}`
|
|
85
73
|
}
|
|
86
|
-
}).
|
|
87
|
-
|
|
74
|
+
}).then((res) => {
|
|
75
|
+
console.log(res["query"]["allpages"]);
|
|
76
|
+
res["query"]["allpages"].forEach(async (element) => {
|
|
77
|
+
console.log(element.title);
|
|
78
|
+
await ctx.database.upsert("wikipages", (row) => [
|
|
79
|
+
{ id: element.pageid, title: element.title.replace("/", "-") }
|
|
80
|
+
]);
|
|
81
|
+
});
|
|
82
|
+
return `更新已完成,已尝试写入数据库}`;
|
|
83
|
+
}).catch((err) => {
|
|
84
|
+
console.log(err);
|
|
85
|
+
return `出现了一点点问题`;
|
|
88
86
|
});
|
|
89
|
-
}
|
|
90
|
-
__name(getWiki, "getWiki");
|
|
87
|
+
});
|
|
91
88
|
ctx.command("doc", "大叔的文档链接").alias("/大叔文档").action(async () => {
|
|
92
89
|
return `大叔的文档链接:
|
|
93
90
|
${config.docUrl}`;
|
|
@@ -102,6 +99,7 @@ __name(apply, "apply");
|
|
|
102
99
|
0 && (module.exports = {
|
|
103
100
|
Config,
|
|
104
101
|
apply,
|
|
102
|
+
inject,
|
|
105
103
|
name,
|
|
106
104
|
usage
|
|
107
105
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-oni-wiki-qq",
|
|
3
3
|
"description": "缺氧wiki查询,自用",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -16,8 +16,5 @@
|
|
|
16
16
|
],
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"koishi": "^4.17.12"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"mwn": "^2.0.3"
|
|
22
19
|
}
|
|
23
20
|
}
|