koishi-plugin-oni-sync-bot 0.3.1 → 0.3.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.
Files changed (2) hide show
  1. package/lib/index.js +13 -10
  2. package/package.json +2 -3
package/lib/index.js CHANGED
@@ -42,7 +42,6 @@ var import_plugin_console = require("@koishijs/plugin-console");
42
42
 
43
43
  // src/utils/login.ts
44
44
  var import_mwn = require("mwn");
45
- var import_tough_cookie = require("tough-cookie");
46
45
 
47
46
  // src/utils/tools.ts
48
47
  var import_koishi = require("koishi");
@@ -103,17 +102,15 @@ async function login(siteConfig) {
103
102
  }
104
103
  });
105
104
  if (siteConfig.name === "bwiki") {
106
- const sessdataCookie = new import_tough_cookie.Cookie({
107
- key: "SESSDATA",
108
- value: "666",
109
- domain: "wiki.biligame.com",
110
- path: "/oni",
111
- httpOnly: true,
112
- secure: true
113
- });
114
- bot.cookieJar.setCookie(sessdataCookie, bot.options.apiUrl, (err) => {
105
+ const cookieString = "SESSDATA=666; Domain=wiki.biligame.com; Path=/oni; HttpOnly; Secure;";
106
+ bot.cookieJar.setCookie(cookieString, bot.options.apiUrl, (err) => {
115
107
  if (err) console.error("Cookie 注入失败:", err);
116
108
  });
109
+ bot.setRequestOptions({
110
+ headers: {
111
+ referer: "https://wiki.biligame.com/oni/"
112
+ }
113
+ });
117
114
  }
118
115
  await bot.login();
119
116
  logger.info(`✅ 成功登录 ${siteConfig.name}`);
@@ -195,6 +192,8 @@ async function syncSingleImage(sourceBot, targetBot, fileName, config) {
195
192
  return { success: false, reason: "source_missing" };
196
193
  }
197
194
  const targetImageInfo = await getImageInfo(targetBot, fileName);
195
+ logger.info(`原图片sha1: ${sourceImageInfo.sha1}`);
196
+ logger.info(`目标图片sha1: ${targetImageInfo.sha1}`);
198
197
  if (targetImageInfo && targetImageInfo.sha1 === sourceImageInfo.sha1) {
199
198
  logger.info(`[SyncImg] 🟡 图片 ${fileName} 已存在且内容一致,跳过`);
200
199
  return { success: true, reason: "no_change" };
@@ -244,6 +243,10 @@ async function syncSingleImage(sourceBot, targetBot, fileName, config) {
244
243
  throw new Error(`未知响应: ${JSON.stringify(responseData)}`);
245
244
  }
246
245
  } catch (error) {
246
+ if (error instanceof Error && error.message.includes("fileexists-no-change")) {
247
+ logger.info(`[SyncImg] 🟡 图片 ${fileName} 已存在且内容相同,跳过`);
248
+ return { success: true, reason: "no_change" };
249
+ }
247
250
  const errMsg = error.message || String(error);
248
251
  logger.error(`[SyncImg] ❌ 图片 ${fileName} 同步失败:`, errMsg);
249
252
  return { success: false, reason: errMsg };
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.3.1",
4
+ "version": "0.3.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -27,7 +27,6 @@
27
27
  "koishi-plugin-cron": "^3.1.0",
28
28
  "mwn": "^3.0.1",
29
29
  "node-fetch": "^3.3.2",
30
- "pinyin-pro": "^3.28.0",
31
- "tough-cookie": "^6.0.1"
30
+ "pinyin-pro": "^3.28.0"
32
31
  }
33
32
  }