koishi-plugin-oni-wiki-qq 0.4.2 → 0.4.4

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 CHANGED
@@ -1,19 +1,23 @@
1
1
  import { Context, Schema } from "koishi";
2
2
  export declare const name = "oni-wiki-qq";
3
- export declare const usage = "\n - 0.4.2 \u4FEE\u6539/ \u7684\u4F7F\u7528\u65B9\u5F0F,\u6539\u4E3A >\n - 0.4.1 \u589E\u52A0/\u7684\u5904\u7406\n - 0.4.0 \u79FB\u9664MWN.\u5C06\u67E5\u8BE2\u5904\u7406\u6539\u81F3\u67E5\u8BE2\u6570\u636E\u5E93\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.4 \u52A0\u5165\u7528\u6237\u9875\u9762\n - 0.4.3 \u6536\u96C6\u641C\u7D22\u7684\u8BCD\u6C47\u9891\u7387\n - 0.4.2 \u4FEE\u6539/ \u7684\u4F7F\u7528\u65B9\u5F0F,\u6539\u4E3A >\n - 0.4.1 \u589E\u52A0/\u7684\u5904\u7406\n - 0.4.0 \u79FB\u9664MWN.\u5C06\u67E5\u8BE2\u5904\u7406\u6539\u81F3\u67E5\u8BE2\u6570\u636E\u5E93\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
4
  export declare const inject: string[];
5
5
  declare module "koishi" {
6
6
  interface Tables {
7
7
  wikipages: WikiPages;
8
+ searchpages: searchPages;
8
9
  }
9
10
  }
10
11
  export interface WikiPages {
11
12
  id: number;
12
13
  title: string;
13
14
  }
15
+ export interface searchPages {
16
+ id: number;
17
+ title: string;
18
+ time: string;
19
+ }
14
20
  export interface Config {
15
- docUrl: string;
16
- Rocket_Calculator: string;
17
21
  SESSDATA: string;
18
22
  }
19
23
  export declare const Config: Schema<Config>;
package/lib/index.js CHANGED
@@ -30,6 +30,8 @@ module.exports = __toCommonJS(src_exports);
30
30
  var import_koishi = require("koishi");
31
31
  var name = "oni-wiki-qq";
32
32
  var usage = `
33
+ - 0.4.4 加入用户页面
34
+ - 0.4.3 收集搜索的词汇频率
33
35
  - 0.4.2 修改/ 的使用方式,改为 >
34
36
  - 0.4.1 增加/的处理
35
37
  - 0.4.0 移除MWN.将查询处理改至查询数据库
@@ -38,8 +40,6 @@ var usage = `
38
40
  `;
39
41
  var inject = ["database"];
40
42
  var Config = import_koishi.Schema.object({
41
- docUrl: import_koishi.Schema.string().default("klei.vip/oni/926f8b").description("大叔的文档地址"),
42
- Rocket_Calculator: import_koishi.Schema.string().description("火箭计算器地址").default("https://klei.vip/oni/t93o56"),
43
43
  SESSDATA: import_koishi.Schema.string().description("SESSDATA")
44
44
  });
45
45
  function apply(ctx, config) {
@@ -48,14 +48,29 @@ function apply(ctx, config) {
48
48
  id: "integer",
49
49
  title: "string"
50
50
  });
51
+ ctx.model.extend(
52
+ "searchpages",
53
+ {
54
+ id: "unsigned",
55
+ title: "string",
56
+ time: "string"
57
+ },
58
+ {
59
+ primary: "id",
60
+ autoInc: true
61
+ }
62
+ );
51
63
  ctx.command("x <itemName>", "查询缺氧中文wiki").alias("/查wiki").action(async ({ session }, itemName = "电解器") => {
52
- session.send(`您查询的「${itemName}」进行中,请稍等...`);
64
+ await ctx.database.create("searchpages", {
65
+ title: itemName,
66
+ time: import_koishi.Time.template("yyyy-MM-dd hh:mm:ss", /* @__PURE__ */ new Date())
67
+ });
53
68
  const res = await ctx.database.get("wikipages", {
54
- title: [`${itemName.replace("/", ">")}`]
69
+ title: [`${itemName}`]
55
70
  });
56
71
  logger.info(res);
57
72
  if (res.length == 0) {
58
- return `在Wiki里没找到或API查询超时,如有需要,请按照游戏内名称重新发起查询....`;
73
+ return `在Wiki里没找到,如有需要,请按照游戏内名称重新发起查询....`;
59
74
  }
60
75
  return `请点击链接前往站点查看:
61
76
  原站点: http://oni.wiki/${encodeURI(
@@ -64,19 +79,29 @@ function apply(ctx, config) {
64
79
  镜像站: https://klei.vip/oni/usiz6d/${encodeURI(itemName)}`;
65
80
  });
66
81
  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`;
82
+ const headers = {
83
+ "Content-Type": "application/json",
84
+ "user-agent": "Charles'queryBot",
85
+ Cookie: `SESSDATA=${config.SESSDATA}`
86
+ };
87
+ const url = `https://wiki.biligame.com/oni/api.php?action=query&list=allpages&apnamespace=0&aplimit=5000&format=json`;
88
+ const user = `https://wiki.biligame.com/oni/api.php?action=query&list=allpages&apnamespace=2&aplimit=5000&format=json`;
89
+ await ctx.http.get(user, { headers }).then((res) => {
90
+ res["query"]["allpages"].forEach(async (element) => {
91
+ console.log(element.title);
92
+ await ctx.database.upsert("wikipages", () => [
93
+ { id: element.pageid, title: element.title }
94
+ ]);
95
+ });
96
+ });
68
97
  return await ctx.http.get(url, {
69
- headers: {
70
- "Content-Type": "application/json",
71
- "user-agent": "Charles'queryBot",
72
- Cookie: `SESSDATA=${config.SESSDATA}`
73
- }
98
+ headers
74
99
  }).then((res) => {
75
100
  console.log(res["query"]["allpages"]);
76
101
  res["query"]["allpages"].forEach(async (element) => {
77
102
  console.log(element.title);
78
- await ctx.database.upsert("wikipages", (row) => [
79
- { id: element.pageid, title: element.title.replace("/", ">") }
103
+ await ctx.database.upsert("wikipages", () => [
104
+ { id: element.pageid, title: element.title }
80
105
  ]);
81
106
  });
82
107
  return `更新已完成,已尝试写入数据库}`;
@@ -87,11 +112,11 @@ function apply(ctx, config) {
87
112
  });
88
113
  ctx.command("doc", "大叔的文档链接").alias("/大叔文档").action(async () => {
89
114
  return `大叔的文档链接:
90
- ${config.docUrl}`;
115
+ https://klei.vip/oni/926f8b`;
91
116
  });
92
117
  ctx.command("RocketCalculator", "火箭计算器").alias("火箭计算器").action(async () => {
93
118
  return `火箭计算器链接:
94
- ${config.Rocket_Calculator}`;
119
+ https://klei.vip/oni/t93o56`;
95
120
  });
96
121
  }
97
122
  __name(apply, "apply");
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.2",
4
+ "version": "0.4.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [