halbot 1995.1.57 → 1995.1.58
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/package.json +2 -2
- package/web/ogimage.mjs +16 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "halbot",
|
|
3
3
|
"description": "Just another AI powered Telegram bot, which is simple design, easy to use, extendable and fun.",
|
|
4
|
-
"version": "1995.1.
|
|
4
|
+
"version": "1995.1.58",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/halbot",
|
|
7
7
|
"type": "module",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"telegraf": "^4.16.3",
|
|
52
52
|
"tellegram": "^1.1.18",
|
|
53
53
|
"tesseract.js": "^7.0.0",
|
|
54
|
-
"webjam": "^1995.3.
|
|
54
|
+
"webjam": "^1995.3.10",
|
|
55
55
|
"youtube-transcript": "^1.2.1"
|
|
56
56
|
}
|
|
57
57
|
}
|
package/web/ogimage.mjs
CHANGED
|
@@ -6,12 +6,25 @@ import { Resvg } from '@resvg/resvg-js';
|
|
|
6
6
|
let interFontBuffer;
|
|
7
7
|
let notoFontBuffer;
|
|
8
8
|
|
|
9
|
+
const fetchWithRetry = async (url, retries = 3) => {
|
|
10
|
+
for (let i = 0; i < retries; i++) {
|
|
11
|
+
try {
|
|
12
|
+
const res = await fetch(url);
|
|
13
|
+
if (!res.ok) throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
14
|
+
return await res.arrayBuffer();
|
|
15
|
+
} catch (e) {
|
|
16
|
+
if (i === retries - 1) throw e;
|
|
17
|
+
await new Promise(r => setTimeout(r, 1000)); // wait 1s before retry
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
9
22
|
const getFonts = async () => {
|
|
10
23
|
if (!interFontBuffer) {
|
|
11
24
|
try {
|
|
25
|
+
// Fetching Inter from Google Fonts per user preference
|
|
12
26
|
const url = 'https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyfAZJhjp-Ek-_EeA.woff';
|
|
13
|
-
|
|
14
|
-
interFontBuffer = await res.arrayBuffer();
|
|
27
|
+
interFontBuffer = await fetchWithRetry(url);
|
|
15
28
|
} catch (e) {
|
|
16
29
|
console.error('Failed to load Inter font:', e);
|
|
17
30
|
throw new Error('Inter Font loading failed');
|
|
@@ -21,9 +34,7 @@ const getFonts = async () => {
|
|
|
21
34
|
try {
|
|
22
35
|
// Fetching a complete Noto Sans TC OTF from JSDelivr to ensure all CJK glyphs load in Satori
|
|
23
36
|
const url = 'https://cdn.jsdelivr.net/gh/googlefonts/noto-cjk@main/Sans/OTF/TraditionalChinese/NotoSansCJKtc-Regular.otf';
|
|
24
|
-
|
|
25
|
-
if (!res.ok) throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
26
|
-
notoFontBuffer = await res.arrayBuffer();
|
|
37
|
+
notoFontBuffer = await fetchWithRetry(url);
|
|
27
38
|
} catch (e) {
|
|
28
39
|
console.error('Failed to load Noto font:', e);
|
|
29
40
|
throw new Error('Noto Font loading failed');
|