koishi-plugin-nitter 0.0.2 → 0.0.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 +13 -2
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -109,7 +109,14 @@ ${JSON.stringify(texts)}`
|
|
|
109
109
|
if (response.data && response.data.choices && response.data.choices[0]) {
|
|
110
110
|
const content = response.data.choices[0].message.content;
|
|
111
111
|
data = JSON.parse(content);
|
|
112
|
-
if (!Array.isArray(data))
|
|
112
|
+
if (!Array.isArray(data)) {
|
|
113
|
+
if (typeof data === "object" && Object.keys(data).length === 1) {
|
|
114
|
+
const keys = Object.keys(data);
|
|
115
|
+
if (!Array.isArray(data[keys[0]]))
|
|
116
|
+
throw new Error("API返回数据格式异常");
|
|
117
|
+
data = data[keys[0]];
|
|
118
|
+
} else throw new Error("API返回数据格式异常");
|
|
119
|
+
}
|
|
113
120
|
} else {
|
|
114
121
|
throw new Error("API返回数据格式异常");
|
|
115
122
|
}
|
|
@@ -300,7 +307,11 @@ async function renderTweetScreenshot(ctx, tweetId, config) {
|
|
|
300
307
|
if (!element2) throw new Error("Rate Limited");
|
|
301
308
|
}, 2e3);
|
|
302
309
|
if (config.enableTranslate) {
|
|
303
|
-
|
|
310
|
+
try {
|
|
311
|
+
await addTranslate(page, ".main-thread .tweet-content, .main-thread .quote-text");
|
|
312
|
+
} catch (e) {
|
|
313
|
+
ctx.logger("nitter").info("翻译失败", e);
|
|
314
|
+
}
|
|
304
315
|
}
|
|
305
316
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
306
317
|
await page.evaluate(() => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-nitter",
|
|
3
3
|
"description": "使用Rettiwt-API订阅推文,并使用nitter渲染",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@satorijs/element": "^3.1.8",
|
|
19
19
|
"axios": "^1.12.2",
|
|
20
|
-
"koishi": "^4.18.9",
|
|
21
|
-
"koishi-plugin-subscription": "^0.0.1",
|
|
22
|
-
"rettiwt-api": "^6.0.6",
|
|
23
20
|
"https-proxy-agent": "^7.0.6",
|
|
24
|
-
"
|
|
21
|
+
"koishi": "^4.18.9",
|
|
22
|
+
"koishi-plugin-subscription": "^0.0.5",
|
|
23
|
+
"node-cron": "^4.2.1",
|
|
24
|
+
"rettiwt-api": "^6.0.6"
|
|
25
25
|
}
|
|
26
26
|
}
|