@zhin.js/plugin-60s 1.1.9 → 1.1.11
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/README.md +6 -0
- package/commands/60s/index.js +2 -2
- package/commands/60s/index.ts +2 -2
- package/commands/bing/index.js +2 -2
- package/commands/bing/index.ts +2 -2
- package/commands/douyin/[[limit]]/index.js +2 -2
- package/commands/douyin/[[limit]]/index.ts +2 -2
- package/commands/duanzi/index.js +2 -2
- package/commands/duanzi/index.ts +2 -2
- package/commands/exchange/index.js +3 -3
- package/commands/exchange/index.ts +3 -3
- package/commands/fanyi/[text]/index.js +2 -2
- package/commands/fanyi/[text]/index.ts +2 -2
- package/commands/fuel/[province]/index.js +2 -2
- package/commands/fuel/[province]/index.ts +2 -2
- package/commands/gold/index.js +2 -2
- package/commands/gold/index.ts +2 -2
- package/commands/history/index.js +2 -2
- package/commands/history/index.ts +2 -2
- package/commands/hitokoto/[type]/index.js +2 -2
- package/commands/hitokoto/[type]/index.ts +2 -2
- package/commands/ip/[ip]/index.js +2 -2
- package/commands/ip/[ip]/index.ts +2 -2
- package/commands/kfc/index.js +2 -2
- package/commands/kfc/index.ts +2 -2
- package/commands/moyu/index.js +2 -2
- package/commands/moyu/index.ts +2 -2
- package/commands/toutiao/[[limit]]/index.js +2 -2
- package/commands/toutiao/[[limit]]/index.ts +2 -2
- package/commands/weather/[city]/index.js +2 -2
- package/commands/weather/[city]/index.ts +2 -2
- package/commands/weibo/[[limit]]/index.js +2 -2
- package/commands/weibo/[[limit]]/index.ts +2 -2
- package/commands/zhihu/[[limit]]/index.js +2 -2
- package/commands/zhihu/[[limit]]/index.ts +2 -2
- package/lib/client.d.ts +2 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +6 -5
- package/lib/client.js.map +1 -1
- package/lib/handlers/60s-news.d.ts +2 -1
- package/lib/handlers/60s-news.d.ts.map +1 -1
- package/lib/handlers/60s-news.js +4 -3
- package/lib/handlers/60s-news.js.map +1 -1
- package/lib/handlers/bing-image.d.ts +2 -1
- package/lib/handlers/bing-image.d.ts.map +1 -1
- package/lib/handlers/bing-image.js +4 -3
- package/lib/handlers/bing-image.js.map +1 -1
- package/lib/handlers/douyin-hot.d.ts +2 -1
- package/lib/handlers/douyin-hot.d.ts.map +1 -1
- package/lib/handlers/douyin-hot.js +4 -3
- package/lib/handlers/douyin-hot.js.map +1 -1
- package/lib/handlers/duanzi.d.ts +2 -1
- package/lib/handlers/duanzi.d.ts.map +1 -1
- package/lib/handlers/duanzi.js +4 -3
- package/lib/handlers/duanzi.js.map +1 -1
- package/lib/handlers/exchange-rate.d.ts +2 -1
- package/lib/handlers/exchange-rate.d.ts.map +1 -1
- package/lib/handlers/exchange-rate.js +6 -5
- package/lib/handlers/exchange-rate.js.map +1 -1
- package/lib/handlers/fuel-price.d.ts +2 -1
- package/lib/handlers/fuel-price.d.ts.map +1 -1
- package/lib/handlers/fuel-price.js +5 -4
- package/lib/handlers/fuel-price.js.map +1 -1
- package/lib/handlers/gold-price.d.ts +2 -1
- package/lib/handlers/gold-price.d.ts.map +1 -1
- package/lib/handlers/gold-price.js +7 -6
- package/lib/handlers/gold-price.js.map +1 -1
- package/lib/handlers/history-today.d.ts +2 -1
- package/lib/handlers/history-today.d.ts.map +1 -1
- package/lib/handlers/history-today.js +5 -4
- package/lib/handlers/history-today.js.map +1 -1
- package/lib/handlers/hitokoto.d.ts +2 -1
- package/lib/handlers/hitokoto.d.ts.map +1 -1
- package/lib/handlers/hitokoto.js +4 -3
- package/lib/handlers/hitokoto.js.map +1 -1
- package/lib/handlers/ip-query.d.ts +2 -1
- package/lib/handlers/ip-query.d.ts.map +1 -1
- package/lib/handlers/ip-query.js +7 -6
- package/lib/handlers/ip-query.js.map +1 -1
- package/lib/handlers/kfc.d.ts +2 -1
- package/lib/handlers/kfc.d.ts.map +1 -1
- package/lib/handlers/kfc.js +4 -3
- package/lib/handlers/kfc.js.map +1 -1
- package/lib/handlers/moyu.d.ts +2 -1
- package/lib/handlers/moyu.d.ts.map +1 -1
- package/lib/handlers/moyu.js +8 -7
- package/lib/handlers/moyu.js.map +1 -1
- package/lib/handlers/toutiao-hot.d.ts +2 -1
- package/lib/handlers/toutiao-hot.d.ts.map +1 -1
- package/lib/handlers/toutiao-hot.js +4 -3
- package/lib/handlers/toutiao-hot.js.map +1 -1
- package/lib/handlers/translate.d.ts +2 -1
- package/lib/handlers/translate.d.ts.map +1 -1
- package/lib/handlers/translate.js +7 -6
- package/lib/handlers/translate.js.map +1 -1
- package/lib/handlers/weather.d.ts +2 -1
- package/lib/handlers/weather.d.ts.map +1 -1
- package/lib/handlers/weather.js +9 -8
- package/lib/handlers/weather.js.map +1 -1
- package/lib/handlers/weibo-hot.d.ts +2 -1
- package/lib/handlers/weibo-hot.d.ts.map +1 -1
- package/lib/handlers/weibo-hot.js +4 -3
- package/lib/handlers/weibo-hot.js.map +1 -1
- package/lib/handlers/zhihu-hot.d.ts +2 -1
- package/lib/handlers/zhihu-hot.d.ts.map +1 -1
- package/lib/handlers/zhihu-hot.js +4 -3
- package/lib/handlers/zhihu-hot.js.map +1 -1
- package/lib/i18n.d.ts +2 -0
- package/lib/i18n.d.ts.map +1 -0
- package/lib/i18n.js +180 -0
- package/lib/i18n.js.map +1 -0
- package/package.json +6 -6
- package/skills/60s-life/tools/duanzi/index.js +1 -1
- package/skills/60s-life/tools/duanzi/index.ts +1 -1
- package/skills/60s-life/tools/history_today/index.js +1 -1
- package/skills/60s-life/tools/history_today/index.ts +1 -1
- package/skills/60s-life/tools/hitokoto/index.js +1 -1
- package/skills/60s-life/tools/hitokoto/index.ts +1 -1
- package/skills/60s-life/tools/kfc/index.js +1 -1
- package/skills/60s-life/tools/kfc/index.ts +1 -1
- package/skills/60s-life/tools/moyu/index.js +1 -1
- package/skills/60s-life/tools/moyu/index.ts +1 -1
- package/skills/60s-life/tools/weather/index.js +1 -1
- package/skills/60s-life/tools/weather/index.ts +1 -1
- package/skills/60s-market/tools/exchange_rate/index.js +1 -1
- package/skills/60s-market/tools/exchange_rate/index.ts +1 -1
- package/skills/60s-market/tools/fuel_price/index.js +1 -1
- package/skills/60s-market/tools/fuel_price/index.ts +1 -1
- package/skills/60s-market/tools/gold_price/index.js +1 -1
- package/skills/60s-market/tools/gold_price/index.ts +1 -1
- package/skills/60s-media/tools/bing_image/index.js +1 -1
- package/skills/60s-media/tools/bing_image/index.ts +1 -1
- package/skills/60s-news/tools/60s_news/index.js +1 -1
- package/skills/60s-news/tools/60s_news/index.ts +1 -1
- package/skills/60s-news/tools/douyin_hot/index.js +1 -1
- package/skills/60s-news/tools/douyin_hot/index.ts +1 -1
- package/skills/60s-news/tools/toutiao_hot/index.js +1 -1
- package/skills/60s-news/tools/toutiao_hot/index.ts +1 -1
- package/skills/60s-news/tools/weibo_hot/index.js +1 -1
- package/skills/60s-news/tools/weibo_hot/index.ts +1 -1
- package/skills/60s-news/tools/zhihu_hot/index.js +1 -1
- package/skills/60s-news/tools/zhihu_hot/index.ts +1 -1
- package/skills/60s-utility/tools/ip_query/index.js +1 -1
- package/skills/60s-utility/tools/ip_query/index.ts +1 -1
- package/skills/60s-utility/tools/translate_60s/index.js +1 -1
- package/skills/60s-utility/tools/translate_60s/index.ts +1 -1
- package/src/client.ts +7 -4
- package/src/handlers/60s-news.ts +5 -3
- package/src/handlers/bing-image.ts +5 -3
- package/src/handlers/douyin-hot.ts +5 -3
- package/src/handlers/duanzi.ts +5 -3
- package/src/handlers/exchange-rate.ts +7 -4
- package/src/handlers/fuel-price.ts +6 -4
- package/src/handlers/gold-price.ts +8 -6
- package/src/handlers/history-today.ts +6 -4
- package/src/handlers/hitokoto.ts +5 -3
- package/src/handlers/ip-query.ts +8 -6
- package/src/handlers/kfc.ts +5 -3
- package/src/handlers/moyu.ts +9 -7
- package/src/handlers/toutiao-hot.ts +5 -3
- package/src/handlers/translate.ts +8 -6
- package/src/handlers/weather.ts +10 -8
- package/src/handlers/weibo-hot.ts +5 -3
- package/src/handlers/zhihu-hot.ts +5 -3
- package/src/i18n.ts +180 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zhihu-hot.js","sourceRoot":"","sources":["../../src/handlers/zhihu-hot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zhihu-hot.js","sourceRoot":"","sources":["../../src/handlers/zhihu-hot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,IAAI,CAAC,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAiB,MAAM,WAAW,CAAC;AAGtD,MAAM,CAAC,OAAO,CAAC,KAAK,WAAW,MAAoB,EAAE,IAAwB,EAAE,MAAe;IAC5F,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAAa,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACzE,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjF,CAAC"}
|
package/lib/i18n.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const messages: (locale: import("zhin.js").Locale | undefined, key: "news" | "weather" | "temperature" | "condition" | "humidity" | "wind" | "air" | "weibo" | "zhihu" | "douyin" | "toutiao" | "hitokoto" | "moyu" | "lunar" | "workday" | "dayoff" | "countdown" | "ip" | "currentIp" | "location" | "isp" | "bing" | "gold" | "goldName" | "goldUnit" | "goldPrice" | "fuel" | "fuelPrice" | "exchange" | "base" | "updated" | "kfc" | "duanzi" | "history" | "monthDay" | "translation" | "source" | "target" | "pronounce" | "requestTimeout" | "requestFailed" | "httpError" | "jsonError" | "apiError", values?: import("zhin.js").MessageValues) => string;
|
|
2
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,onBAiLnB,CAAC"}
|
package/lib/i18n.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { createMessages } from 'zhin.js/i18n';
|
|
2
|
+
export const messages = createMessages({
|
|
3
|
+
"news": {
|
|
4
|
+
"zh-CN": "📰 今日60秒新闻 ({date})",
|
|
5
|
+
"en": "📰 60-second daily news ({date})"
|
|
6
|
+
},
|
|
7
|
+
"weather": {
|
|
8
|
+
"zh-CN": "🌤️ {city} 天气",
|
|
9
|
+
"en": "🌤️ Weather in {city}"
|
|
10
|
+
},
|
|
11
|
+
"temperature": {
|
|
12
|
+
"zh-CN": "🌡️ 温度: {value}°C",
|
|
13
|
+
"en": "🌡️ Temperature: {value}°C"
|
|
14
|
+
},
|
|
15
|
+
"condition": {
|
|
16
|
+
"zh-CN": "☁️ 天气: {value}",
|
|
17
|
+
"en": "☁️ Conditions: {value}"
|
|
18
|
+
},
|
|
19
|
+
"humidity": {
|
|
20
|
+
"zh-CN": "💧 湿度: {value}%",
|
|
21
|
+
"en": "💧 Humidity: {value}%"
|
|
22
|
+
},
|
|
23
|
+
"wind": {
|
|
24
|
+
"zh-CN": "💨 风: {direction} {power}",
|
|
25
|
+
"en": "💨 Wind: {direction} {power}"
|
|
26
|
+
},
|
|
27
|
+
"air": {
|
|
28
|
+
"zh-CN": "🌬️ 空气: {value}",
|
|
29
|
+
"en": "🌬️ Air quality: {value}"
|
|
30
|
+
},
|
|
31
|
+
"weibo": {
|
|
32
|
+
"zh-CN": "🔥 微博热搜",
|
|
33
|
+
"en": "🔥 Weibo trending"
|
|
34
|
+
},
|
|
35
|
+
"zhihu": {
|
|
36
|
+
"zh-CN": "🔥 知乎热榜",
|
|
37
|
+
"en": "🔥 Zhihu trending"
|
|
38
|
+
},
|
|
39
|
+
"douyin": {
|
|
40
|
+
"zh-CN": "🔥 抖音热搜",
|
|
41
|
+
"en": "🔥 Douyin trending"
|
|
42
|
+
},
|
|
43
|
+
"toutiao": {
|
|
44
|
+
"zh-CN": "🔥 头条热搜",
|
|
45
|
+
"en": "🔥 Toutiao trending"
|
|
46
|
+
},
|
|
47
|
+
"hitokoto": {
|
|
48
|
+
"zh-CN": "💬 一言",
|
|
49
|
+
"en": "💬 Quote"
|
|
50
|
+
},
|
|
51
|
+
"moyu": {
|
|
52
|
+
"zh-CN": "🐟 摸鱼日历",
|
|
53
|
+
"en": "🐟 Leisure calendar"
|
|
54
|
+
},
|
|
55
|
+
"lunar": {
|
|
56
|
+
"zh-CN": "🌙 农历{month}{day} {year}年",
|
|
57
|
+
"en": "🌙 Lunar date: {month}{day}, {year}"
|
|
58
|
+
},
|
|
59
|
+
"workday": {
|
|
60
|
+
"zh-CN": "💼 今天是工作日",
|
|
61
|
+
"en": "💼 Today is a workday"
|
|
62
|
+
},
|
|
63
|
+
"dayoff": {
|
|
64
|
+
"zh-CN": "🎮 今天不上班",
|
|
65
|
+
"en": "🎮 Today is a day off"
|
|
66
|
+
},
|
|
67
|
+
"countdown": {
|
|
68
|
+
"zh-CN": "⏳ 距 {name} 还有 {days} 天",
|
|
69
|
+
"en": "⏳ {days} days until {name}"
|
|
70
|
+
},
|
|
71
|
+
"ip": {
|
|
72
|
+
"zh-CN": "🌐 IP 查询",
|
|
73
|
+
"en": "🌐 IP lookup"
|
|
74
|
+
},
|
|
75
|
+
"currentIp": {
|
|
76
|
+
"zh-CN": "当前 IP",
|
|
77
|
+
"en": "Current IP"
|
|
78
|
+
},
|
|
79
|
+
"location": {
|
|
80
|
+
"zh-CN": "位置: {value}",
|
|
81
|
+
"en": "Location: {value}"
|
|
82
|
+
},
|
|
83
|
+
"isp": {
|
|
84
|
+
"zh-CN": "运营商: {value}",
|
|
85
|
+
"en": "ISP: {value}"
|
|
86
|
+
},
|
|
87
|
+
"bing": {
|
|
88
|
+
"zh-CN": "🖼️ Bing 每日壁纸",
|
|
89
|
+
"en": "🖼️ Bing daily wallpaper"
|
|
90
|
+
},
|
|
91
|
+
"gold": {
|
|
92
|
+
"zh-CN": "💰 今日金价",
|
|
93
|
+
"en": "💰 Gold prices today"
|
|
94
|
+
},
|
|
95
|
+
"goldName": {
|
|
96
|
+
"zh-CN": "黄金",
|
|
97
|
+
"en": "Gold"
|
|
98
|
+
},
|
|
99
|
+
"goldUnit": {
|
|
100
|
+
"zh-CN": "元/克",
|
|
101
|
+
"en": "CNY/g"
|
|
102
|
+
},
|
|
103
|
+
"goldPrice": {
|
|
104
|
+
"zh-CN": "当前金价: ¥{price}/克",
|
|
105
|
+
"en": "Current gold price: ¥{price}/g"
|
|
106
|
+
},
|
|
107
|
+
"fuel": {
|
|
108
|
+
"zh-CN": "⛽ 今日油价",
|
|
109
|
+
"en": "⛽ Fuel prices today"
|
|
110
|
+
},
|
|
111
|
+
"fuelPrice": {
|
|
112
|
+
"zh-CN": "¥{price}/升",
|
|
113
|
+
"en": "¥{price}/L"
|
|
114
|
+
},
|
|
115
|
+
"exchange": {
|
|
116
|
+
"zh-CN": "💱 汇率查询",
|
|
117
|
+
"en": "💱 Exchange rates"
|
|
118
|
+
},
|
|
119
|
+
"base": {
|
|
120
|
+
"zh-CN": "基准货币: {value}",
|
|
121
|
+
"en": "Base currency: {value}"
|
|
122
|
+
},
|
|
123
|
+
"updated": {
|
|
124
|
+
"zh-CN": "更新时间: {value}",
|
|
125
|
+
"en": "Updated: {value}"
|
|
126
|
+
},
|
|
127
|
+
"kfc": {
|
|
128
|
+
"zh-CN": "🍗 疯狂星期四",
|
|
129
|
+
"en": "🍗 KFC Thursday"
|
|
130
|
+
},
|
|
131
|
+
"duanzi": {
|
|
132
|
+
"zh-CN": "😂 段子",
|
|
133
|
+
"en": "😂 Joke"
|
|
134
|
+
},
|
|
135
|
+
"history": {
|
|
136
|
+
"zh-CN": "📅 历史上的今天 ({date})",
|
|
137
|
+
"en": "📅 Today in history ({date})"
|
|
138
|
+
},
|
|
139
|
+
"monthDay": {
|
|
140
|
+
"zh-CN": "{month}月{day}日",
|
|
141
|
+
"en": "{month}/{day}"
|
|
142
|
+
},
|
|
143
|
+
"translation": {
|
|
144
|
+
"zh-CN": "🌐 翻译结果",
|
|
145
|
+
"en": "🌐 Translation"
|
|
146
|
+
},
|
|
147
|
+
"source": {
|
|
148
|
+
"zh-CN": "原文{language}: {text}",
|
|
149
|
+
"en": "Original{language}: {text}"
|
|
150
|
+
},
|
|
151
|
+
"target": {
|
|
152
|
+
"zh-CN": "译文{language}: {text}",
|
|
153
|
+
"en": "Translation{language}: {text}"
|
|
154
|
+
},
|
|
155
|
+
"pronounce": {
|
|
156
|
+
"zh-CN": "发音: {value}",
|
|
157
|
+
"en": "Pronunciation: {value}"
|
|
158
|
+
},
|
|
159
|
+
"requestTimeout": {
|
|
160
|
+
"zh-CN": "请求超时(30s)",
|
|
161
|
+
"en": "Request timed out after 30s."
|
|
162
|
+
},
|
|
163
|
+
"requestFailed": {
|
|
164
|
+
"zh-CN": "请求失败: {detail}",
|
|
165
|
+
"en": "Request failed: {detail}"
|
|
166
|
+
},
|
|
167
|
+
"httpError": {
|
|
168
|
+
"zh-CN": "API 请求失败: {status} {text}",
|
|
169
|
+
"en": "API request failed: {status} {text}"
|
|
170
|
+
},
|
|
171
|
+
"jsonError": {
|
|
172
|
+
"zh-CN": "API 返回非 JSON 响应 (content-type: {type})",
|
|
173
|
+
"en": "API returned a non-JSON response (content-type: {type})"
|
|
174
|
+
},
|
|
175
|
+
"apiError": {
|
|
176
|
+
"zh-CN": "API 错误: {code}",
|
|
177
|
+
"en": "API error: {code}"
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
//# sourceMappingURL=i18n.js.map
|
package/lib/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC;IACrC,MAAM,EAAE;QACN,OAAO,EAAE,qBAAqB;QAC9B,IAAI,EAAE,kCAAkC;KACzC;IACD,SAAS,EAAE;QACT,OAAO,EAAE,eAAe;QACxB,IAAI,EAAE,uBAAuB;KAC9B;IACD,aAAa,EAAE;QACb,OAAO,EAAE,mBAAmB;QAC5B,IAAI,EAAE,4BAA4B;KACnC;IACD,WAAW,EAAE;QACX,OAAO,EAAE,gBAAgB;QACzB,IAAI,EAAE,wBAAwB;KAC/B;IACD,UAAU,EAAE;QACV,OAAO,EAAE,iBAAiB;QAC1B,IAAI,EAAE,uBAAuB;KAC9B;IACD,MAAM,EAAE;QACN,OAAO,EAAE,2BAA2B;QACpC,IAAI,EAAE,8BAA8B;KACrC;IACD,KAAK,EAAE;QACL,OAAO,EAAE,iBAAiB;QAC1B,IAAI,EAAE,0BAA0B;KACjC;IACD,OAAO,EAAE;QACP,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,mBAAmB;KAC1B;IACD,OAAO,EAAE;QACP,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,mBAAmB;KAC1B;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,oBAAoB;KAC3B;IACD,SAAS,EAAE;QACT,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,qBAAqB;KAC5B;IACD,UAAU,EAAE;QACV,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,UAAU;KACjB;IACD,MAAM,EAAE;QACN,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,qBAAqB;KAC5B;IACD,OAAO,EAAE;QACP,OAAO,EAAE,2BAA2B;QACpC,IAAI,EAAE,qCAAqC;KAC5C;IACD,SAAS,EAAE;QACT,OAAO,EAAE,WAAW;QACpB,IAAI,EAAE,uBAAuB;KAC9B;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,uBAAuB;KAC9B;IACD,WAAW,EAAE;QACX,OAAO,EAAE,wBAAwB;QACjC,IAAI,EAAE,4BAA4B;KACnC;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,cAAc;KACrB;IACD,WAAW,EAAE;QACX,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,YAAY;KACnB;IACD,UAAU,EAAE;QACV,OAAO,EAAE,aAAa;QACtB,IAAI,EAAE,mBAAmB;KAC1B;IACD,KAAK,EAAE;QACL,OAAO,EAAE,cAAc;QACvB,IAAI,EAAE,cAAc;KACrB;IACD,MAAM,EAAE;QACN,OAAO,EAAE,eAAe;QACxB,IAAI,EAAE,0BAA0B;KACjC;IACD,MAAM,EAAE;QACN,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,sBAAsB;KAC7B;IACD,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,MAAM;KACb;IACD,UAAU,EAAE;QACV,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,OAAO;KACd;IACD,WAAW,EAAE;QACX,OAAO,EAAE,kBAAkB;QAC3B,IAAI,EAAE,gCAAgC;KACvC;IACD,MAAM,EAAE;QACN,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,qBAAqB;KAC5B;IACD,WAAW,EAAE;QACX,OAAO,EAAE,YAAY;QACrB,IAAI,EAAE,YAAY;KACnB;IACD,UAAU,EAAE;QACV,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,mBAAmB;KAC1B;IACD,MAAM,EAAE;QACN,OAAO,EAAE,eAAe;QACxB,IAAI,EAAE,wBAAwB;KAC/B;IACD,SAAS,EAAE;QACT,OAAO,EAAE,eAAe;QACxB,IAAI,EAAE,kBAAkB;KACzB;IACD,KAAK,EAAE;QACL,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,iBAAiB;KACxB;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,SAAS;KAChB;IACD,SAAS,EAAE;QACT,OAAO,EAAE,oBAAoB;QAC7B,IAAI,EAAE,8BAA8B;KACrC;IACD,UAAU,EAAE;QACV,OAAO,EAAE,gBAAgB;QACzB,IAAI,EAAE,eAAe;KACtB;IACD,aAAa,EAAE;QACb,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,gBAAgB;KACvB;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,sBAAsB;QAC/B,IAAI,EAAE,4BAA4B;KACnC;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,sBAAsB;QAC/B,IAAI,EAAE,+BAA+B;KACtC;IACD,WAAW,EAAE;QACX,OAAO,EAAE,aAAa;QACtB,IAAI,EAAE,wBAAwB;KAC/B;IACD,gBAAgB,EAAE;QAChB,OAAO,EAAE,WAAW;QACpB,IAAI,EAAE,8BAA8B;KACrC;IACD,eAAe,EAAE;QACf,OAAO,EAAE,gBAAgB;QACzB,IAAI,EAAE,0BAA0B;KACjC;IACD,WAAW,EAAE;QACX,OAAO,EAAE,2BAA2B;QACpC,IAAI,EAAE,qCAAqC;KAC5C;IACD,WAAW,EAAE;QACX,OAAO,EAAE,wCAAwC;QACjD,IAAI,EAAE,yDAAyD;KAChE;IACD,UAAU,EAAE;QACV,OAAO,EAAE,gBAAgB;QACzB,IAAI,EAAE,mBAAmB;KAC1B;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/plugin-60s",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "60s API aggregation plugin for Zhin.js — news, weather, hot searches, utilities (Plugin Runtime)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -45,19 +45,19 @@
|
|
|
45
45
|
},
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@zhin.js/tool": "1.1.
|
|
49
|
-
"@zhin.js/skill": "1.1.
|
|
48
|
+
"@zhin.js/tool": "1.1.11",
|
|
49
|
+
"@zhin.js/skill": "1.1.10"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"typescript": "^6.0.3",
|
|
53
53
|
"vitest": "^4.1.10",
|
|
54
54
|
"zod": "^4.4.3",
|
|
55
|
-
"zhin.js": "1.1.
|
|
55
|
+
"zhin.js": "1.1.17"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"zod": "^4.0.0",
|
|
59
|
-
"@zhin.js/command": "^1.1.
|
|
60
|
-
"zhin.js": "^1.1.
|
|
59
|
+
"@zhin.js/command": "^1.1.11",
|
|
60
|
+
"zhin.js": "^1.1.17"
|
|
61
61
|
},
|
|
62
62
|
"peerDependenciesMeta": {
|
|
63
63
|
"@zhin.js/command": {
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["娱乐", "笑话", "段子"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/duanzi.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["娱乐", "笑话", "段子"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/duanzi.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["历史", "知识", "日历"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/history-today.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["历史", "知识", "日历"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/history-today.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["语录", "文学", "随机"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/hitokoto.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool<{ type?: string }>({
|
|
|
9
9
|
tags: ["语录", "文学", "随机"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/hitokoto.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["娱乐", "KFC", "文案"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/kfc.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["娱乐", "KFC", "文案"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/kfc.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["生活", "摸鱼", "日历"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/moyu.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["生活", "摸鱼", "日历"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/moyu.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["天气", "生活", "查询"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/weather.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool<{ city: string }>({
|
|
|
9
9
|
tags: ["天气", "生活", "查询"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/weather.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["金融", "汇率", "查询"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/exchange-rate.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool<{ from?: string; to?: string }>({
|
|
|
9
9
|
tags: ["金融", "汇率", "查询"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/exchange-rate.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["生活", "油价", "价格"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/fuel-price.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool<{ province?: string }>({
|
|
|
9
9
|
tags: ["生活", "油价", "价格"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/fuel-price.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["金融", "黄金", "价格"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/gold-price.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["金融", "黄金", "价格"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/gold-price.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["图片", "壁纸", "Bing"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/bing-image.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["图片", "壁纸", "Bing"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/bing-image.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["新闻", "资讯", "60s"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/60s-news.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["新闻", "资讯", "60s"],
|
|
10
10
|
async execute(_input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/60s-news.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken));
|
|
12
|
+
return handler(context.use(sixtySClientToken), context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["热搜", "短视频", "抖音"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/douyin-hot.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool<{ limit?: number }>({
|
|
|
9
9
|
tags: ["热搜", "短视频", "抖音"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/douyin-hot.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["热搜", "资讯", "头条"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/toutiao-hot.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool<{ limit?: number }>({
|
|
|
9
9
|
tags: ["热搜", "资讯", "头条"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/toutiao-hot.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["热搜", "社交", "微博"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/weibo-hot.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool<{ limit?: number }>({
|
|
|
9
9
|
tags: ["热搜", "社交", "微博"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/weibo-hot.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["热搜", "社交", "知乎"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/zhihu-hot.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool<{ limit?: number }>({
|
|
|
9
9
|
tags: ["热搜", "社交", "知乎"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/zhihu-hot.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["网络", "查询", "IP"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/ip-query.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool<{ ip?: string }>({
|
|
|
9
9
|
tags: ["网络", "查询", "IP"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/ip-query.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool({
|
|
|
9
9
|
tags: ["工具", "翻译", "语言"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import("../../../../lib/handlers/translate.js")).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -9,6 +9,6 @@ export default defineAgentTool<{ text: string; to?: string }>({
|
|
|
9
9
|
tags: ["工具", "翻译", "语言"],
|
|
10
10
|
async execute(input, context) {
|
|
11
11
|
const handler = (await import('../../../../src/handlers/translate.js')).default;
|
|
12
|
-
return handler(context.use(sixtySClientToken), input);
|
|
12
|
+
return handler(context.use(sixtySClientToken), input, context.locale);
|
|
13
13
|
},
|
|
14
14
|
});
|
package/src/client.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from './i18n.js';
|
|
1
3
|
import { createToken } from 'zhin.js';
|
|
2
4
|
|
|
3
5
|
export const DEFAULT_API_BASE = 'https://60s.viki.moe';
|
|
@@ -19,6 +21,7 @@ export class SixtySClient {
|
|
|
19
21
|
async fetch<T = Record<string, unknown>>(
|
|
20
22
|
endpoint: string,
|
|
21
23
|
params?: Readonly<Record<string, string>>,
|
|
24
|
+
locale?: Locale,
|
|
22
25
|
): Promise<T> {
|
|
23
26
|
const url = new URL(`${this.apiBase}/v2${endpoint}`);
|
|
24
27
|
for (const [key, value] of Object.entries(params ?? {})) {
|
|
@@ -30,16 +33,16 @@ export class SixtySClient {
|
|
|
30
33
|
} catch (error) {
|
|
31
34
|
const cause = error as Error;
|
|
32
35
|
throw new Error(
|
|
33
|
-
cause.name === 'TimeoutError' ? '
|
|
36
|
+
cause.name === 'TimeoutError' ? t(locale, 'requestTimeout') : t(locale, 'requestFailed', { detail: cause.message }),
|
|
34
37
|
{ cause: error },
|
|
35
38
|
);
|
|
36
39
|
}
|
|
37
40
|
if (!response.ok) {
|
|
38
|
-
throw new Error(
|
|
41
|
+
throw new Error(t(locale, 'httpError', { status: response.status, text: response.statusText }));
|
|
39
42
|
}
|
|
40
43
|
const contentType = response.headers.get('content-type') ?? '';
|
|
41
44
|
if (!contentType.includes('application/json')) {
|
|
42
|
-
throw new Error(
|
|
45
|
+
throw new Error(t(locale, 'jsonError', { type: contentType || 'unknown' }));
|
|
43
46
|
}
|
|
44
47
|
const envelope = (await response.json()) as {
|
|
45
48
|
error?: string;
|
|
@@ -50,7 +53,7 @@ export class SixtySClient {
|
|
|
50
53
|
};
|
|
51
54
|
if (envelope.error) throw new Error(envelope.error);
|
|
52
55
|
if (envelope.code !== undefined && envelope.code !== 200 && envelope.code !== 0) {
|
|
53
|
-
throw new Error(envelope.message || envelope.msg ||
|
|
56
|
+
throw new Error(envelope.message || envelope.msg || t(locale, 'apiError', { code: envelope.code }));
|
|
54
57
|
}
|
|
55
58
|
return (envelope.data ?? envelope) as T;
|
|
56
59
|
}
|
package/src/handlers/60s-news.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import type { SixtySClient } from '../client.js';
|
|
2
4
|
|
|
3
|
-
export default async function (client: SixtySClient) {
|
|
4
|
-
const data = await client.fetch('/60s');
|
|
5
|
-
const lines = [
|
|
5
|
+
export default async function (client: SixtySClient, locale?: Locale) {
|
|
6
|
+
const data = await client.fetch('/60s', undefined, locale);
|
|
7
|
+
const lines = [t(locale, 'news', { date: String(data.date || '') }), ''];
|
|
6
8
|
if (data.news && Array.isArray(data.news)) {
|
|
7
9
|
lines.push(...data.news.map((n: string, i: number) => `${i + 1}. ${n}`));
|
|
8
10
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import { asString } from '../api.js';
|
|
2
4
|
import type { SixtySClient } from '../client.js';
|
|
3
5
|
|
|
4
|
-
export default async function (client: SixtySClient) {
|
|
5
|
-
const data = await client.fetch('/bing');
|
|
6
|
-
const lines = [
|
|
6
|
+
export default async function (client: SixtySClient, locale?: Locale) {
|
|
7
|
+
const data = await client.fetch('/bing', undefined, locale);
|
|
8
|
+
const lines = [t(locale, 'bing'), ''];
|
|
7
9
|
if (data.title) lines.push(`📌 ${data.title}`);
|
|
8
10
|
if (data.headline) lines.push(`💡 ${data.headline}`);
|
|
9
11
|
if (data.copyright) lines.push(`📝 ${data.copyright}`);
|