koishi-plugin-oni-sync-bot 0.3.3 → 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.
- package/lib/index.js +12 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -102,10 +102,15 @@ async function login(siteConfig) {
|
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
if (siteConfig.name === "bwiki") {
|
|
105
|
-
const cookieString = "SESSDATA=666; Domain=wiki.biligame.com; Path=/oni; HttpOnly; Secure";
|
|
105
|
+
const cookieString = "SESSDATA=666; Domain=wiki.biligame.com; Path=/oni; HttpOnly; Secure;";
|
|
106
106
|
bot.cookieJar.setCookie(cookieString, bot.options.apiUrl, (err) => {
|
|
107
107
|
if (err) console.error("Cookie 注入失败:", err);
|
|
108
108
|
});
|
|
109
|
+
bot.setRequestOptions({
|
|
110
|
+
headers: {
|
|
111
|
+
referer: "https://wiki.biligame.com/oni/"
|
|
112
|
+
}
|
|
113
|
+
});
|
|
109
114
|
}
|
|
110
115
|
await bot.login();
|
|
111
116
|
logger.info(`✅ 成功登录 ${siteConfig.name}`);
|
|
@@ -187,6 +192,8 @@ async function syncSingleImage(sourceBot, targetBot, fileName, config) {
|
|
|
187
192
|
return { success: false, reason: "source_missing" };
|
|
188
193
|
}
|
|
189
194
|
const targetImageInfo = await getImageInfo(targetBot, fileName);
|
|
195
|
+
logger.info(`原图片sha1: ${sourceImageInfo.sha1}`);
|
|
196
|
+
logger.info(`目标图片sha1: ${targetImageInfo.sha1}`);
|
|
190
197
|
if (targetImageInfo && targetImageInfo.sha1 === sourceImageInfo.sha1) {
|
|
191
198
|
logger.info(`[SyncImg] 🟡 图片 ${fileName} 已存在且内容一致,跳过`);
|
|
192
199
|
return { success: true, reason: "no_change" };
|
|
@@ -236,6 +243,10 @@ async function syncSingleImage(sourceBot, targetBot, fileName, config) {
|
|
|
236
243
|
throw new Error(`未知响应: ${JSON.stringify(responseData)}`);
|
|
237
244
|
}
|
|
238
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
|
+
}
|
|
239
250
|
const errMsg = error.message || String(error);
|
|
240
251
|
logger.error(`[SyncImg] ❌ 图片 ${fileName} 同步失败:`, errMsg);
|
|
241
252
|
return { success: false, reason: errMsg };
|