koishi-plugin-oni-wiki-qq 0.2.0 → 0.2.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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Context, Schema } from "koishi";
2
2
  export declare const name = "oni-wiki-qq";
3
3
  export declare const inject: string[];
4
- export declare const usage = "\n - 0.2.0 \u5C1D\u8BD5\u6DFB\u52A0 MWN \u5E93\n - 0.1.0 \u6DFB\u52A0\u767B\u5F55\u548C\u70B9\u51FBcookies\u6309\u94AE,\u5220\u9664\u6CA1\u6CD5\u5224\u65AD\u7B54\u6848\u7684\u4EE3\u7801\n - 0.0.9 \u5C1D\u8BD5\u79FB\u9664\u5BFC\u822A\u6846,\u66F4\u65B0koishi\u4F9D\u8D56\n";
4
+ export declare const usage = "\n - 0.2.1 \u4EA4\u6362\u56FE\u7247\u548C\u6D88\u606F\u4F4D\u7F6E\u4EE5\u4F7Fqq\u53D1\u9001\u65F6\u5728\u540C\u4E00\u6D88\u606F\u907F\u514D\u5237\u5C4F\n - 0.2.0 \u5C1D\u8BD5\u6DFB\u52A0 MWN \u5E93\n - 0.1.0 \u6DFB\u52A0\u767B\u5F55\u548C\u70B9\u51FBcookies\u6309\u94AE,\u5220\u9664\u6CA1\u6CD5\u5224\u65AD\u7B54\u6848\u7684\u4EE3\u7801\n";
5
5
  export interface Config {
6
6
  api: string;
7
7
  imgPath: string;
package/lib/index.js CHANGED
@@ -72,6 +72,7 @@ async function getWiki(itemName, config) {
72
72
  redirects: "return",
73
73
  format: "json"
74
74
  }).then(async (res) => {
75
+ console.log(res);
75
76
  if (res[1][0] == itemName) {
76
77
  return res[3][0];
77
78
  } else {
@@ -85,9 +86,9 @@ __name(getWiki, "getWiki");
85
86
  var name = "oni-wiki-qq";
86
87
  var inject = ["puppeteer"];
87
88
  var usage = `
89
+ - 0.2.1 交换图片和消息位置以使qq发送时在同一消息避免刷屏
88
90
  - 0.2.0 尝试添加 MWN 库
89
91
  - 0.1.0 添加登录和点击cookies按钮,删除没法判断答案的代码
90
- - 0.0.9 尝试移除导航框,更新koishi依赖
91
92
  `;
92
93
  var Config = import_koishi.Schema.object({
93
94
  api: import_koishi.Schema.string().default("https://oxygennotincluded.wiki.gg/zh/api.php").description("api地址"),
@@ -122,23 +123,21 @@ function apply(ctx, config) {
122
123
  if (checkFileExists(filePath)) {
123
124
  return (0, import_koishi.h)(
124
125
  "p",
125
- `图片已保存至:${encodeURI(urlPath)}`,
126
- (0, import_koishi.h)("img", { src: `${encodeURI(urlPath)}` })
126
+ (0, import_koishi.h)("img", { src: `${encodeURI(urlPath)}` }),
127
+ `图片已保存至:${encodeURI(urlPath)}`
127
128
  );
128
129
  }
129
130
  session.send(`您查询的「${itemName}」进行中,请稍等...`);
130
- await (0, import_koishi.sleep)(500);
131
131
  const res = await getWiki(itemName, config);
132
132
  if (!res) {
133
133
  return `在Wiki里没找到或API查询超时,如有需要,请按照游戏内名称重新发起查询....`;
134
134
  }
135
135
  let screenShotRes = await screenShot(res);
136
- logger.info(`API返回的数据为: ${screenShotRes}`);
137
136
  if (screenShotRes) {
138
137
  return (0, import_koishi.h)(
139
138
  "p",
140
- `图片已保存至:${encodeURI(urlPath)}`,
141
- (0, import_koishi.h)("img", { src: `${encodeURI(urlPath)}` })
139
+ (0, import_koishi.h)("img", { src: `${encodeURI(urlPath)}` }),
140
+ `图片已保存至:${encodeURI(urlPath)}`
142
141
  );
143
142
  } else {
144
143
  return `截图发生错误.请稍后重试..`;
@@ -155,16 +154,15 @@ function apply(ctx, config) {
155
154
  try {
156
155
  await page.$eval(config.navSelector, (el) => el.remove());
157
156
  } catch (error) {
158
- logger.error(error);
159
157
  }
160
158
  const selector = await page.$(config.contentSelector);
161
159
  return await selector.screenshot({
162
160
  type: "jpeg",
163
- quality: 50,
161
+ quality: 60,
164
162
  path: filePath
165
163
  }).then(() => {
166
164
  return true;
167
- }).catch(async (err) => {
165
+ }).catch((err) => {
168
166
  logger.error(err);
169
167
  return false;
170
168
  }).finally(async () => await page.close());
@@ -207,7 +205,7 @@ function apply(ctx, config) {
207
205
  await (0, import_koishi.sleep)(5e3);
208
206
  session.send(
209
207
  import_koishi.h.image(
210
- await page.screenshot({ type: "jpeg", quality: 80 }),
208
+ await page.screenshot({ type: "jpeg", quality: 75 }),
211
209
  "jpeg/image"
212
210
  )
213
211
  );
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.2.0",
4
+ "version": "0.2.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [