@zhin.js/plugin-60s 1.1.9 → 1.1.10
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,7 +1,9 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import { formatList, type ListItem } from '../api.js';
|
|
2
4
|
import type { SixtySClient } from '../client.js';
|
|
3
5
|
|
|
4
|
-
export default async function (client: SixtySClient, args: { limit?: number }) {
|
|
5
|
-
const data = await client.fetch<ListItem[]>('/douyin');
|
|
6
|
-
return [
|
|
6
|
+
export default async function (client: SixtySClient, args: { limit?: number }, locale?: Locale) {
|
|
7
|
+
const data = await client.fetch<ListItem[]>('/douyin', undefined, locale);
|
|
8
|
+
return [t(locale, 'douyin'), '', formatList(data, args.limit || 10)].join('\n');
|
|
7
9
|
}
|
package/src/handlers/duanzi.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
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('/duanzi');
|
|
5
|
-
return
|
|
5
|
+
export default async function (client: SixtySClient, locale?: Locale) {
|
|
6
|
+
const data = await client.fetch('/duanzi', undefined, locale);
|
|
7
|
+
return `${t(locale, 'duanzi')}\n\n${data.duanzi || data.content || data.text || (typeof data === 'string' ? data : '')}`;
|
|
6
8
|
}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import { asArray, asRecord, asString } from '../api.js';
|
|
2
4
|
import type { SixtySClient } from '../client.js';
|
|
3
5
|
|
|
4
|
-
export default async function (client: SixtySClient, args: { from?: string; to?: string }) {
|
|
6
|
+
export default async function (client: SixtySClient, args: { from?: string; to?: string }, locale?: Locale) {
|
|
5
7
|
const params: Record<string, string> = {};
|
|
6
8
|
if (args.from) params.from = args.from.toUpperCase();
|
|
7
9
|
if (args.to) params.to = args.to.toUpperCase();
|
|
8
10
|
const data = await client.fetch(
|
|
9
11
|
'/exchange-rate',
|
|
10
12
|
Object.keys(params).length ? params : undefined,
|
|
13
|
+
locale,
|
|
11
14
|
);
|
|
12
|
-
const lines = [
|
|
15
|
+
const lines = [t(locale, 'exchange'), ''];
|
|
13
16
|
const base = data.base_code || args.from || 'CNY';
|
|
14
|
-
lines.push(
|
|
15
|
-
if (data.updated) lines.push(
|
|
17
|
+
lines.push(t(locale, 'base', { value: String(base) }));
|
|
18
|
+
if (data.updated) lines.push(t(locale, 'updated', { value: String(data.updated) }));
|
|
16
19
|
lines.push('');
|
|
17
20
|
const rates = asArray(data.rates);
|
|
18
21
|
const targetCurrencies = args.to
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import { asRecord, asString } from '../api.js';
|
|
2
4
|
import type { SixtySClient } from '../client.js';
|
|
3
5
|
|
|
4
|
-
export default async function (client: SixtySClient, args: { province?: string }) {
|
|
6
|
+
export default async function (client: SixtySClient, args: { province?: string }, locale?: Locale) {
|
|
5
7
|
const params: Record<string, string> | undefined = args.province
|
|
6
8
|
? { province: args.province }
|
|
7
9
|
: undefined;
|
|
8
|
-
const data = await client.fetch('/fuel-price', params);
|
|
9
|
-
const lines = [
|
|
10
|
+
const data = await client.fetch('/fuel-price', params, locale);
|
|
11
|
+
const lines = [t(locale, 'fuel'), ''];
|
|
10
12
|
if (data.region) lines.push(`📍 ${data.region}`);
|
|
11
13
|
if (data.items && Array.isArray(data.items)) {
|
|
12
14
|
data.items.forEach((item: Record<string, unknown>) => {
|
|
13
|
-
lines.push(`${item.name}: ${item.price_desc ||
|
|
15
|
+
lines.push(`${item.name}: ${item.price_desc || t(locale, 'fuelPrice', { price: String(item.price) })}`);
|
|
14
16
|
});
|
|
15
17
|
}
|
|
16
18
|
if (data.trend) {
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import { asArray, asRecord } 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('/gold-price');
|
|
6
|
-
const lines = [
|
|
6
|
+
export default async function (client: SixtySClient, locale?: Locale) {
|
|
7
|
+
const data = await client.fetch('/gold-price', undefined, locale);
|
|
8
|
+
const lines = [t(locale, 'gold'), ''];
|
|
7
9
|
if (data.date) lines.push(`📅 ${data.date}`);
|
|
8
10
|
const metals = asArray(data.metals);
|
|
9
11
|
if (metals.length > 0) {
|
|
10
12
|
lines.push('');
|
|
11
13
|
metals.forEach((item) => {
|
|
12
14
|
const row = asRecord(item);
|
|
13
|
-
const name = row.name || '
|
|
15
|
+
const name = row.name || t(locale, 'goldName');
|
|
14
16
|
const price = row.today_price || row.sell_price || row.price || 'N/A';
|
|
15
|
-
const unit = row.unit || '
|
|
17
|
+
const unit = row.unit || t(locale, 'goldUnit');
|
|
16
18
|
if (price !== 'N/A') lines.push(`${name}: ¥${price} ${unit}`);
|
|
17
19
|
});
|
|
18
20
|
} else if (data.price) {
|
|
19
|
-
lines.push(
|
|
21
|
+
lines.push(t(locale, 'goldPrice', { price: String(data.price) }));
|
|
20
22
|
}
|
|
21
23
|
return lines.join('\n');
|
|
22
24
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import { asArray, asRecord } 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('/today-in-history');
|
|
6
|
-
const dateStr = data.date ||
|
|
7
|
-
const lines = [
|
|
6
|
+
export default async function (client: SixtySClient, locale?: Locale) {
|
|
7
|
+
const data = await client.fetch('/today-in-history', undefined, locale);
|
|
8
|
+
const dateStr = data.date || t(locale, 'monthDay', { month: String(data.month || ''), day: String(data.day || '') });
|
|
9
|
+
const lines = [t(locale, 'history', { date: String(dateStr) }), ''];
|
|
8
10
|
const items = asArray(data.items);
|
|
9
11
|
items.slice(0, 10).forEach((item, i: number) => {
|
|
10
12
|
const row = asRecord(item);
|
package/src/handlers/hitokoto.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
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, args: { type?: string }) {
|
|
5
|
+
export default async function (client: SixtySClient, args: { type?: string }, locale?: Locale) {
|
|
4
6
|
const params: Record<string, string> | undefined = args.type
|
|
5
7
|
? { c: args.type }
|
|
6
8
|
: undefined;
|
|
7
|
-
const data = await client.fetch('/hitokoto', params);
|
|
9
|
+
const data = await client.fetch('/hitokoto', params, locale);
|
|
8
10
|
const text = data.hitokoto || data.content || (typeof data === 'string' ? data : '');
|
|
9
|
-
const lines = [
|
|
11
|
+
const lines = [t(locale, 'hitokoto'), '', `「${text}」`];
|
|
10
12
|
if (data.from || data.source || data.from_who || data.author) {
|
|
11
13
|
const author = data.from_who || data.author || '';
|
|
12
14
|
const source = data.from || data.source || '';
|
package/src/handlers/ip-query.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
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, args: { ip?: string }) {
|
|
5
|
+
export default async function (client: SixtySClient, args: { ip?: string }, locale?: Locale) {
|
|
4
6
|
const params: Record<string, string> | undefined = args.ip
|
|
5
7
|
? { ip: args.ip }
|
|
6
8
|
: undefined;
|
|
7
|
-
const data = await client.fetch('/ip', params);
|
|
8
|
-
const lines = [
|
|
9
|
+
const data = await client.fetch('/ip', params, locale);
|
|
10
|
+
const lines = [t(locale, 'ip'), '', `IP: ${data.ip || args.ip || t(locale, 'currentIp')}`];
|
|
9
11
|
if (data.country || data.region || data.city) {
|
|
10
|
-
lines.push(
|
|
12
|
+
lines.push(t(locale, 'location', { value: [data.country, data.region, data.city].filter(Boolean).join(' ') }));
|
|
11
13
|
}
|
|
12
|
-
if (data.location) lines.push(
|
|
13
|
-
if (data.isp) lines.push(
|
|
14
|
+
if (data.location) lines.push(t(locale, 'location', { value: String(data.location) }));
|
|
15
|
+
if (data.isp) lines.push(t(locale, 'isp', { value: String(data.isp) }));
|
|
14
16
|
return lines.join('\n');
|
|
15
17
|
}
|
package/src/handlers/kfc.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
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('/kfc');
|
|
5
|
-
return
|
|
5
|
+
export default async function (client: SixtySClient, locale?: Locale) {
|
|
6
|
+
const data = await client.fetch('/kfc', undefined, locale);
|
|
7
|
+
return `${t(locale, 'kfc')}\n\n${data.kfc || data.content || data.text || (typeof data === 'string' ? data : '')}`;
|
|
6
8
|
}
|
package/src/handlers/moyu.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import { asArray, asRecord, asString, type ApiPayload } 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<ApiPayload | string>('/moyu');
|
|
6
|
-
if (typeof data === 'string') return
|
|
7
|
-
const lines = [
|
|
6
|
+
export default async function (client: SixtySClient, locale?: Locale) {
|
|
7
|
+
const data = await client.fetch<ApiPayload | string>('/moyu', undefined, locale);
|
|
8
|
+
if (typeof data === 'string') return `${t(locale, 'moyu')}\n\n${data}`;
|
|
9
|
+
const lines = [t(locale, 'moyu'), ''];
|
|
8
10
|
const date = asRecord(data.date);
|
|
9
11
|
if (date.gregorian) lines.push(`📅 ${date.gregorian} ${asString(date.weekday)}`);
|
|
10
12
|
const lunar = asRecord(date.lunar);
|
|
11
13
|
if (lunar.monthCN || lunar.dayCN) {
|
|
12
|
-
lines.push(
|
|
14
|
+
lines.push(t(locale, 'lunar', { month: asString(lunar.monthCN), day: asString(lunar.dayCN), year: asString(lunar.yearGanZhi) }));
|
|
13
15
|
}
|
|
14
16
|
const today = asRecord(data.today);
|
|
15
17
|
if (today.holidayName) lines.push(`🎉 ${today.holidayName}`);
|
|
16
18
|
if (today.solarTerm) lines.push(`🌿 ${today.solarTerm}`);
|
|
17
19
|
if (today.isWorkday !== undefined) {
|
|
18
|
-
lines.push(today.isWorkday ?
|
|
20
|
+
lines.push(today.isWorkday ? t(locale, 'workday') : t(locale, 'dayoff'));
|
|
19
21
|
}
|
|
20
22
|
if (Array.isArray(data.festivals)) {
|
|
21
23
|
data.festivals.forEach((f: unknown) => {
|
|
@@ -28,7 +30,7 @@ export default async function (client: SixtySClient) {
|
|
|
28
30
|
countdown.forEach((c: unknown) => {
|
|
29
31
|
const row = asRecord(c);
|
|
30
32
|
if (typeof row.name === 'string' && typeof row.days === 'number') {
|
|
31
|
-
lines.push(
|
|
33
|
+
lines.push(t(locale, 'countdown', { name: row.name, days: row.days }));
|
|
32
34
|
}
|
|
33
35
|
});
|
|
34
36
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import { formatList, type ListItem } from '../api.js';
|
|
2
4
|
import type { SixtySClient } from '../client.js';
|
|
3
5
|
|
|
4
|
-
export default async function (client: SixtySClient, args: { limit?: number }) {
|
|
5
|
-
const data = await client.fetch<ListItem[]>('/toutiao');
|
|
6
|
-
return [
|
|
6
|
+
export default async function (client: SixtySClient, args: { limit?: number }, locale?: Locale) {
|
|
7
|
+
const data = await client.fetch<ListItem[]>('/toutiao', undefined, locale);
|
|
8
|
+
return [t(locale, 'toutiao'), '', formatList(data, args.limit || 10)].join('\n');
|
|
7
9
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import { asRecord, asString } from '../api.js';
|
|
2
4
|
import type { SixtySClient } from '../client.js';
|
|
3
5
|
|
|
4
|
-
export default async function (client: SixtySClient, args: { text: string; to?: string }) {
|
|
6
|
+
export default async function (client: SixtySClient, args: { text: string; to?: string }, locale?: Locale) {
|
|
5
7
|
const params: Record<string, string> = { text: args.text };
|
|
6
8
|
if (args.to) params.to = args.to;
|
|
7
|
-
const data = await client.fetch('/fanyi', params);
|
|
9
|
+
const data = await client.fetch('/fanyi', params, locale);
|
|
8
10
|
const source = asRecord(data.source);
|
|
9
11
|
const target = asRecord(data.target);
|
|
10
12
|
const srcText = asString(source.text) || args.text;
|
|
@@ -16,11 +18,11 @@ export default async function (client: SixtySClient, args: { text: string; to?:
|
|
|
16
18
|
(typeof data === 'string' ? data : '');
|
|
17
19
|
const tgtLang = asString(target.type_desc) || asString(target.type);
|
|
18
20
|
const lines = [
|
|
19
|
-
|
|
21
|
+
t(locale, 'translation'),
|
|
20
22
|
'',
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
t(locale, 'source', { language: srcLang ? ` (${srcLang})` : '', text: srcText }),
|
|
24
|
+
t(locale, 'target', { language: tgtLang ? ` (${tgtLang})` : '', text: tgtText }),
|
|
23
25
|
];
|
|
24
|
-
if (target.pronounce) lines.push(
|
|
26
|
+
if (target.pronounce) lines.push(t(locale, 'pronounce', { value: asString(target.pronounce) }));
|
|
25
27
|
return lines.join('\n');
|
|
26
28
|
}
|
package/src/handlers/weather.ts
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import { asRecord, asString } from '../api.js';
|
|
2
4
|
import type { SixtySClient } from '../client.js';
|
|
3
5
|
|
|
4
|
-
export default async function (client: SixtySClient, args: { city: string }) {
|
|
5
|
-
const data = await client.fetch('/weather', { query: args.city });
|
|
6
|
+
export default async function (client: SixtySClient, args: { city: string }, locale?: Locale) {
|
|
7
|
+
const data = await client.fetch('/weather', { query: args.city }, locale);
|
|
6
8
|
const w = asRecord(data.weather);
|
|
7
9
|
const aq = asRecord(data.air_quality);
|
|
8
10
|
const loc = asRecord(data.location);
|
|
9
11
|
const cityName = asString(loc.city) || asString(loc.name) || args.city;
|
|
10
12
|
const lines = [
|
|
11
|
-
|
|
13
|
+
t(locale, 'weather', { city: cityName }),
|
|
12
14
|
'',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
t(locale, 'temperature', { value: asString(w.temperature) }),
|
|
16
|
+
t(locale, 'condition', { value: asString(w.condition) }),
|
|
17
|
+
t(locale, 'humidity', { value: asString(w.humidity) }),
|
|
18
|
+
t(locale, 'wind', { direction: asString(w.wind_direction), power: asString(w.wind_power) }),
|
|
17
19
|
];
|
|
18
20
|
if (Object.keys(aq).length > 0) {
|
|
19
21
|
const quality = asString(aq.quality);
|
|
20
|
-
lines.push(
|
|
22
|
+
lines.push(t(locale, 'air', { value: `${quality}${aq.aqi ? ` (AQI ${asString(aq.aqi)})` : ''}` }));
|
|
21
23
|
}
|
|
22
24
|
return lines.join('\n');
|
|
23
25
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import { formatList, type ListItem } from '../api.js';
|
|
2
4
|
import type { SixtySClient } from '../client.js';
|
|
3
5
|
|
|
4
|
-
export default async function (client: SixtySClient, args: { limit?: number }) {
|
|
5
|
-
const data = await client.fetch<ListItem[]>('/weibo');
|
|
6
|
-
return [
|
|
6
|
+
export default async function (client: SixtySClient, args: { limit?: number }, locale?: Locale) {
|
|
7
|
+
const data = await client.fetch<ListItem[]>('/weibo', undefined, locale);
|
|
8
|
+
return [t(locale, 'weibo'), '', formatList(data, args.limit || 10)].join('\n');
|
|
7
9
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { Locale } from 'zhin.js/i18n';
|
|
2
|
+
import { messages as t } from '../i18n.js';
|
|
1
3
|
import { formatList, type ListItem } from '../api.js';
|
|
2
4
|
import type { SixtySClient } from '../client.js';
|
|
3
5
|
|
|
4
|
-
export default async function (client: SixtySClient, args: { limit?: number }) {
|
|
5
|
-
const data = await client.fetch<ListItem[]>('/zhihu');
|
|
6
|
-
return [
|
|
6
|
+
export default async function (client: SixtySClient, args: { limit?: number }, locale?: Locale) {
|
|
7
|
+
const data = await client.fetch<ListItem[]>('/zhihu', undefined, locale);
|
|
8
|
+
return [t(locale, 'zhihu'), '', formatList(data, args.limit || 10)].join('\n');
|
|
7
9
|
}
|
package/src/i18n.ts
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { createMessages } from 'zhin.js/i18n';
|
|
2
|
+
|
|
3
|
+
export const messages = createMessages({
|
|
4
|
+
"news": {
|
|
5
|
+
"zh-CN": "📰 今日60秒新闻 ({date})",
|
|
6
|
+
"en": "📰 60-second daily news ({date})"
|
|
7
|
+
},
|
|
8
|
+
"weather": {
|
|
9
|
+
"zh-CN": "🌤️ {city} 天气",
|
|
10
|
+
"en": "🌤️ Weather in {city}"
|
|
11
|
+
},
|
|
12
|
+
"temperature": {
|
|
13
|
+
"zh-CN": "🌡️ 温度: {value}°C",
|
|
14
|
+
"en": "🌡️ Temperature: {value}°C"
|
|
15
|
+
},
|
|
16
|
+
"condition": {
|
|
17
|
+
"zh-CN": "☁️ 天气: {value}",
|
|
18
|
+
"en": "☁️ Conditions: {value}"
|
|
19
|
+
},
|
|
20
|
+
"humidity": {
|
|
21
|
+
"zh-CN": "💧 湿度: {value}%",
|
|
22
|
+
"en": "💧 Humidity: {value}%"
|
|
23
|
+
},
|
|
24
|
+
"wind": {
|
|
25
|
+
"zh-CN": "💨 风: {direction} {power}",
|
|
26
|
+
"en": "💨 Wind: {direction} {power}"
|
|
27
|
+
},
|
|
28
|
+
"air": {
|
|
29
|
+
"zh-CN": "🌬️ 空气: {value}",
|
|
30
|
+
"en": "🌬️ Air quality: {value}"
|
|
31
|
+
},
|
|
32
|
+
"weibo": {
|
|
33
|
+
"zh-CN": "🔥 微博热搜",
|
|
34
|
+
"en": "🔥 Weibo trending"
|
|
35
|
+
},
|
|
36
|
+
"zhihu": {
|
|
37
|
+
"zh-CN": "🔥 知乎热榜",
|
|
38
|
+
"en": "🔥 Zhihu trending"
|
|
39
|
+
},
|
|
40
|
+
"douyin": {
|
|
41
|
+
"zh-CN": "🔥 抖音热搜",
|
|
42
|
+
"en": "🔥 Douyin trending"
|
|
43
|
+
},
|
|
44
|
+
"toutiao": {
|
|
45
|
+
"zh-CN": "🔥 头条热搜",
|
|
46
|
+
"en": "🔥 Toutiao trending"
|
|
47
|
+
},
|
|
48
|
+
"hitokoto": {
|
|
49
|
+
"zh-CN": "💬 一言",
|
|
50
|
+
"en": "💬 Quote"
|
|
51
|
+
},
|
|
52
|
+
"moyu": {
|
|
53
|
+
"zh-CN": "🐟 摸鱼日历",
|
|
54
|
+
"en": "🐟 Leisure calendar"
|
|
55
|
+
},
|
|
56
|
+
"lunar": {
|
|
57
|
+
"zh-CN": "🌙 农历{month}{day} {year}年",
|
|
58
|
+
"en": "🌙 Lunar date: {month}{day}, {year}"
|
|
59
|
+
},
|
|
60
|
+
"workday": {
|
|
61
|
+
"zh-CN": "💼 今天是工作日",
|
|
62
|
+
"en": "💼 Today is a workday"
|
|
63
|
+
},
|
|
64
|
+
"dayoff": {
|
|
65
|
+
"zh-CN": "🎮 今天不上班",
|
|
66
|
+
"en": "🎮 Today is a day off"
|
|
67
|
+
},
|
|
68
|
+
"countdown": {
|
|
69
|
+
"zh-CN": "⏳ 距 {name} 还有 {days} 天",
|
|
70
|
+
"en": "⏳ {days} days until {name}"
|
|
71
|
+
},
|
|
72
|
+
"ip": {
|
|
73
|
+
"zh-CN": "🌐 IP 查询",
|
|
74
|
+
"en": "🌐 IP lookup"
|
|
75
|
+
},
|
|
76
|
+
"currentIp": {
|
|
77
|
+
"zh-CN": "当前 IP",
|
|
78
|
+
"en": "Current IP"
|
|
79
|
+
},
|
|
80
|
+
"location": {
|
|
81
|
+
"zh-CN": "位置: {value}",
|
|
82
|
+
"en": "Location: {value}"
|
|
83
|
+
},
|
|
84
|
+
"isp": {
|
|
85
|
+
"zh-CN": "运营商: {value}",
|
|
86
|
+
"en": "ISP: {value}"
|
|
87
|
+
},
|
|
88
|
+
"bing": {
|
|
89
|
+
"zh-CN": "🖼️ Bing 每日壁纸",
|
|
90
|
+
"en": "🖼️ Bing daily wallpaper"
|
|
91
|
+
},
|
|
92
|
+
"gold": {
|
|
93
|
+
"zh-CN": "💰 今日金价",
|
|
94
|
+
"en": "💰 Gold prices today"
|
|
95
|
+
},
|
|
96
|
+
"goldName": {
|
|
97
|
+
"zh-CN": "黄金",
|
|
98
|
+
"en": "Gold"
|
|
99
|
+
},
|
|
100
|
+
"goldUnit": {
|
|
101
|
+
"zh-CN": "元/克",
|
|
102
|
+
"en": "CNY/g"
|
|
103
|
+
},
|
|
104
|
+
"goldPrice": {
|
|
105
|
+
"zh-CN": "当前金价: ¥{price}/克",
|
|
106
|
+
"en": "Current gold price: ¥{price}/g"
|
|
107
|
+
},
|
|
108
|
+
"fuel": {
|
|
109
|
+
"zh-CN": "⛽ 今日油价",
|
|
110
|
+
"en": "⛽ Fuel prices today"
|
|
111
|
+
},
|
|
112
|
+
"fuelPrice": {
|
|
113
|
+
"zh-CN": "¥{price}/升",
|
|
114
|
+
"en": "¥{price}/L"
|
|
115
|
+
},
|
|
116
|
+
"exchange": {
|
|
117
|
+
"zh-CN": "💱 汇率查询",
|
|
118
|
+
"en": "💱 Exchange rates"
|
|
119
|
+
},
|
|
120
|
+
"base": {
|
|
121
|
+
"zh-CN": "基准货币: {value}",
|
|
122
|
+
"en": "Base currency: {value}"
|
|
123
|
+
},
|
|
124
|
+
"updated": {
|
|
125
|
+
"zh-CN": "更新时间: {value}",
|
|
126
|
+
"en": "Updated: {value}"
|
|
127
|
+
},
|
|
128
|
+
"kfc": {
|
|
129
|
+
"zh-CN": "🍗 疯狂星期四",
|
|
130
|
+
"en": "🍗 KFC Thursday"
|
|
131
|
+
},
|
|
132
|
+
"duanzi": {
|
|
133
|
+
"zh-CN": "😂 段子",
|
|
134
|
+
"en": "😂 Joke"
|
|
135
|
+
},
|
|
136
|
+
"history": {
|
|
137
|
+
"zh-CN": "📅 历史上的今天 ({date})",
|
|
138
|
+
"en": "📅 Today in history ({date})"
|
|
139
|
+
},
|
|
140
|
+
"monthDay": {
|
|
141
|
+
"zh-CN": "{month}月{day}日",
|
|
142
|
+
"en": "{month}/{day}"
|
|
143
|
+
},
|
|
144
|
+
"translation": {
|
|
145
|
+
"zh-CN": "🌐 翻译结果",
|
|
146
|
+
"en": "🌐 Translation"
|
|
147
|
+
},
|
|
148
|
+
"source": {
|
|
149
|
+
"zh-CN": "原文{language}: {text}",
|
|
150
|
+
"en": "Original{language}: {text}"
|
|
151
|
+
},
|
|
152
|
+
"target": {
|
|
153
|
+
"zh-CN": "译文{language}: {text}",
|
|
154
|
+
"en": "Translation{language}: {text}"
|
|
155
|
+
},
|
|
156
|
+
"pronounce": {
|
|
157
|
+
"zh-CN": "发音: {value}",
|
|
158
|
+
"en": "Pronunciation: {value}"
|
|
159
|
+
},
|
|
160
|
+
"requestTimeout": {
|
|
161
|
+
"zh-CN": "请求超时(30s)",
|
|
162
|
+
"en": "Request timed out after 30s."
|
|
163
|
+
},
|
|
164
|
+
"requestFailed": {
|
|
165
|
+
"zh-CN": "请求失败: {detail}",
|
|
166
|
+
"en": "Request failed: {detail}"
|
|
167
|
+
},
|
|
168
|
+
"httpError": {
|
|
169
|
+
"zh-CN": "API 请求失败: {status} {text}",
|
|
170
|
+
"en": "API request failed: {status} {text}"
|
|
171
|
+
},
|
|
172
|
+
"jsonError": {
|
|
173
|
+
"zh-CN": "API 返回非 JSON 响应 (content-type: {type})",
|
|
174
|
+
"en": "API returned a non-JSON response (content-type: {type})"
|
|
175
|
+
},
|
|
176
|
+
"apiError": {
|
|
177
|
+
"zh-CN": "API 错误: {code}",
|
|
178
|
+
"en": "API error: {code}"
|
|
179
|
+
}
|
|
180
|
+
});
|