@zhin.js/plugin-60s 3.0.1 → 3.0.3
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/agent/tools/60s_news.ts +13 -0
- package/agent/tools/bing_image.ts +13 -0
- package/agent/tools/douyin_hot.ts +13 -0
- package/agent/tools/duanzi.ts +13 -0
- package/agent/tools/exchange_rate.ts +13 -0
- package/agent/tools/fuel_price.ts +13 -0
- package/agent/tools/gold_price.ts +13 -0
- package/agent/tools/history_today.ts +13 -0
- package/agent/tools/hitokoto.ts +13 -0
- package/agent/tools/ip_query.ts +13 -0
- package/agent/tools/kfc.ts +13 -0
- package/agent/tools/moyu.ts +13 -0
- package/agent/tools/toutiao_hot.ts +13 -0
- package/agent/tools/translate_60s.ts +13 -0
- package/agent/tools/weather.ts +13 -0
- package/agent/tools/weibo_hot.ts +13 -0
- package/agent/tools/zhihu_hot.ts +13 -0
- package/commands/60s.ts +7 -0
- package/commands/bing.ts +7 -0
- package/commands/douyin/[limit:number=10].ts +7 -0
- package/commands/duanzi.ts +7 -0
- package/commands/exchange.ts +10 -0
- package/commands/fanyi/[text:string].ts +7 -0
- package/commands/fuel/[province:string].ts +7 -0
- package/commands/gold.ts +7 -0
- package/commands/history.ts +7 -0
- package/commands/hitokoto/[type:string].ts +7 -0
- package/commands/ip/[ip:string].ts +7 -0
- package/commands/kfc.ts +7 -0
- package/commands/moyu.ts +7 -0
- package/commands/toutiao/[limit:number=10].ts +7 -0
- package/commands/weather/[city:string].ts +7 -0
- package/commands/weibo/[limit:number=10].ts +7 -0
- package/commands/zhihu/[limit:number=10].ts +7 -0
- package/lib/api.js +45 -0
- package/lib/api.js.map +1 -0
- package/lib/handlers/60s-news.js +12 -0
- package/lib/handlers/60s-news.js.map +1 -0
- package/lib/handlers/bing-image.js +18 -0
- package/lib/handlers/bing-image.js.map +1 -0
- package/lib/handlers/douyin-hot.js +6 -0
- package/lib/handlers/douyin-hot.js.map +1 -0
- package/lib/handlers/duanzi.js +6 -0
- package/lib/handlers/duanzi.js.map +1 -0
- package/lib/handlers/exchange-rate.js +28 -0
- package/lib/handlers/exchange-rate.js.map +1 -0
- package/lib/handlers/fuel-price.js +21 -0
- package/lib/handlers/fuel-price.js.map +1 -0
- package/lib/handlers/gold-price.js +24 -0
- package/lib/handlers/gold-price.js.map +1 -0
- package/lib/handlers/history-today.js +16 -0
- package/lib/handlers/history-today.js.map +1 -0
- package/lib/handlers/hitokoto.js +16 -0
- package/lib/handlers/hitokoto.js.map +1 -0
- package/lib/handlers/ip-query.js +17 -0
- package/lib/handlers/ip-query.js.map +1 -0
- package/lib/handlers/kfc.js +6 -0
- package/lib/handlers/kfc.js.map +1 -0
- package/lib/handlers/moyu.js +39 -0
- package/lib/handlers/moyu.js.map +1 -0
- package/lib/handlers/toutiao-hot.js +6 -0
- package/lib/handlers/toutiao-hot.js.map +1 -0
- package/lib/handlers/translate.js +26 -0
- package/lib/handlers/translate.js.map +1 -0
- package/lib/handlers/weather.js +22 -0
- package/lib/handlers/weather.js.map +1 -0
- package/lib/handlers/weibo-hot.js +6 -0
- package/lib/handlers/weibo-hot.js.map +1 -0
- package/lib/handlers/zhihu-hot.js +6 -0
- package/lib/handlers/zhihu-hot.js.map +1 -0
- package/lib/index.js +1 -34
- package/lib/index.js.map +1 -1
- package/package.json +48 -12
- package/plugin.ts +18 -0
- package/schema.json +12 -0
- package/src/api.ts +63 -0
- package/{tools/60s-news/handler.ts → src/handlers/60s-news.ts} +1 -1
- package/{tools/bing-image/handler.ts → src/handlers/bing-image.ts} +4 -4
- package/{tools/douyin-hot/handler.ts → src/handlers/douyin-hot.ts} +2 -2
- package/{tools/duanzi/handler.ts → src/handlers/duanzi.ts} +1 -1
- package/{tools/exchange-rate/handler.ts → src/handlers/exchange-rate.ts} +8 -6
- package/{tools/fuel-price/handler.ts → src/handlers/fuel-price.ts} +5 -4
- package/{tools/gold-price/handler.ts → src/handlers/gold-price.ts} +8 -7
- package/src/handlers/history-today.ts +16 -0
- package/{tools/hitokoto/handler.ts → src/handlers/hitokoto.ts} +1 -1
- package/{tools/ip-query/handler.ts → src/handlers/ip-query.ts} +1 -1
- package/{tools/kfc/handler.ts → src/handlers/kfc.ts} +1 -1
- package/src/handlers/moyu.ts +35 -0
- package/{tools/toutiao-hot/handler.ts → src/handlers/toutiao-hot.ts} +2 -2
- package/src/handlers/translate.ts +25 -0
- package/src/handlers/weather.ts +22 -0
- package/{tools/weibo-hot/handler.ts → src/handlers/weibo-hot.ts} +2 -2
- package/{tools/zhihu-hot/handler.ts → src/handlers/zhihu-hot.ts} +2 -2
- package/src/index.ts +8 -44
- package/lib/index.d.ts +0 -2
- package/lib/index.d.ts.map +0 -1
- package/plugin.yml +0 -3
- package/tools/60s-news/60s-news.tool.md +0 -8
- package/tools/api.ts +0 -34
- package/tools/bing-image/bing-image.tool.md +0 -8
- package/tools/douyin-hot/douyin-hot.tool.md +0 -12
- package/tools/duanzi/duanzi.tool.md +0 -8
- package/tools/exchange-rate/exchange-rate.tool.md +0 -14
- package/tools/fuel-price/fuel-price.tool.md +0 -11
- package/tools/gold-price/gold-price.tool.md +0 -8
- package/tools/history-today/handler.ts +0 -15
- package/tools/history-today/history-today.tool.md +0 -8
- package/tools/hitokoto/hitokoto.tool.md +0 -12
- package/tools/ip-query/ip-query.tool.md +0 -12
- package/tools/kfc/kfc.tool.md +0 -8
- package/tools/moyu/handler.ts +0 -28
- package/tools/moyu/moyu.tool.md +0 -8
- package/tools/toutiao-hot/toutiao-hot.tool.md +0 -12
- package/tools/translate/handler.ts +0 -19
- package/tools/translate/translate.tool.md +0 -15
- package/tools/weather/handler.ts +0 -22
- package/tools/weather/weather.tool.md +0 -12
- package/tools/weibo-hot/weibo-hot.tool.md +0 -12
- package/tools/zhihu-hot/zhihu-hot.tool.md +0 -12
- /package/{skills/60s/SKILL.md → agent/skills/60s.md} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { asArray, asRecord, asString, fetchApi, type ApiPayload } from '../api.js';
|
|
2
|
+
|
|
3
|
+
export default async function () {
|
|
4
|
+
const data = await fetchApi<ApiPayload | string>('/moyu');
|
|
5
|
+
if (typeof data === 'string') return `🐟 摸鱼日历\n\n${data}`;
|
|
6
|
+
const lines = ['🐟 摸鱼日历', ''];
|
|
7
|
+
const date = asRecord(data.date);
|
|
8
|
+
if (date.gregorian) lines.push(`📅 ${date.gregorian} ${asString(date.weekday)}`);
|
|
9
|
+
const lunar = asRecord(date.lunar);
|
|
10
|
+
if (lunar.monthCN || lunar.dayCN) {
|
|
11
|
+
lines.push(`🌙 农历${asString(lunar.monthCN)}${asString(lunar.dayCN)} ${asString(lunar.yearGanZhi)}年`);
|
|
12
|
+
}
|
|
13
|
+
const today = asRecord(data.today);
|
|
14
|
+
if (today.holidayName) lines.push(`🎉 ${today.holidayName}`);
|
|
15
|
+
if (today.solarTerm) lines.push(`🌿 ${today.solarTerm}`);
|
|
16
|
+
if (today.isWorkday !== undefined) {
|
|
17
|
+
lines.push(today.isWorkday ? '💼 今天是工作日' : '🎮 今天不上班');
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(data.festivals)) {
|
|
20
|
+
data.festivals.forEach((f: unknown) => {
|
|
21
|
+
lines.push(`🎊 ${typeof f === 'string' ? f : asString(asRecord(f).name ?? f)}`);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const countdown = asArray(data.countdown);
|
|
25
|
+
if (countdown.length > 0) {
|
|
26
|
+
lines.push('');
|
|
27
|
+
countdown.forEach((c: unknown) => {
|
|
28
|
+
const row = asRecord(c);
|
|
29
|
+
if (typeof row.name === 'string' && typeof row.days === 'number') {
|
|
30
|
+
lines.push(`⏳ 距 ${row.name} 还有 ${row.days} 天`);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return lines.join('\n');
|
|
35
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { fetchApi, formatList } from '../api.js';
|
|
1
|
+
import { fetchApi, formatList, type ListItem } from '../api.js';
|
|
2
2
|
|
|
3
3
|
export default async function (args: { limit?: number }) {
|
|
4
|
-
const data = await fetchApi<
|
|
4
|
+
const data = await fetchApi<ListItem[]>('/toutiao');
|
|
5
5
|
return ['🔥 头条热搜', '', formatList(data, args.limit || 10)].join('\n');
|
|
6
6
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { asRecord, asString, fetchApi } from '../api.js';
|
|
2
|
+
|
|
3
|
+
export default async function (args: { text: string; to?: string }) {
|
|
4
|
+
const params: Record<string, string> = { text: args.text };
|
|
5
|
+
if (args.to) params.to = args.to;
|
|
6
|
+
const data = await fetchApi('/fanyi', params);
|
|
7
|
+
const source = asRecord(data.source);
|
|
8
|
+
const target = asRecord(data.target);
|
|
9
|
+
const srcText = asString(source.text) || args.text;
|
|
10
|
+
const srcLang = asString(source.type_desc) || asString(source.type);
|
|
11
|
+
const tgtText =
|
|
12
|
+
asString(target.text) ||
|
|
13
|
+
asString(data.result) ||
|
|
14
|
+
asString(data.translation) ||
|
|
15
|
+
(typeof data === 'string' ? data : '');
|
|
16
|
+
const tgtLang = asString(target.type_desc) || asString(target.type);
|
|
17
|
+
const lines = [
|
|
18
|
+
'🌐 翻译结果',
|
|
19
|
+
'',
|
|
20
|
+
`原文${srcLang ? ` (${srcLang})` : ''}: ${srcText}`,
|
|
21
|
+
`译文${tgtLang ? ` (${tgtLang})` : ''}: ${tgtText}`,
|
|
22
|
+
];
|
|
23
|
+
if (target.pronounce) lines.push(`发音: ${asString(target.pronounce)}`);
|
|
24
|
+
return lines.join('\n');
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { asRecord, asString, fetchApi } from '../api.js';
|
|
2
|
+
|
|
3
|
+
export default async function (args: { city: string }) {
|
|
4
|
+
const data = await fetchApi('/weather', { query: args.city });
|
|
5
|
+
const w = asRecord(data.weather);
|
|
6
|
+
const aq = asRecord(data.air_quality);
|
|
7
|
+
const loc = asRecord(data.location);
|
|
8
|
+
const cityName = asString(loc.city) || asString(loc.name) || args.city;
|
|
9
|
+
const lines = [
|
|
10
|
+
`🌤️ ${cityName} 天气`,
|
|
11
|
+
'',
|
|
12
|
+
`🌡️ 温度: ${asString(w.temperature)}°C`,
|
|
13
|
+
`☁️ 天气: ${asString(w.condition)}`,
|
|
14
|
+
`💧 湿度: ${asString(w.humidity)}%`,
|
|
15
|
+
`💨 风: ${asString(w.wind_direction)} ${asString(w.wind_power)}`,
|
|
16
|
+
];
|
|
17
|
+
if (Object.keys(aq).length > 0) {
|
|
18
|
+
const quality = asString(aq.quality);
|
|
19
|
+
lines.push(`🌬️ 空气: ${quality}${aq.aqi ? ` (AQI ${asString(aq.aqi)})` : ''}`);
|
|
20
|
+
}
|
|
21
|
+
return lines.join('\n');
|
|
22
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { fetchApi, formatList } from '../api.js';
|
|
1
|
+
import { fetchApi, formatList, type ListItem } from '../api.js';
|
|
2
2
|
|
|
3
3
|
export default async function (args: { limit?: number }) {
|
|
4
|
-
const data = await fetchApi<
|
|
4
|
+
const data = await fetchApi<ListItem[]>('/weibo');
|
|
5
5
|
return ['🔥 微博热搜', '', formatList(data, args.limit || 10)].join('\n');
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { fetchApi, formatList } from '../api.js';
|
|
1
|
+
import { fetchApi, formatList, type ListItem } from '../api.js';
|
|
2
2
|
|
|
3
3
|
export default async function (args: { limit?: number }) {
|
|
4
|
-
const data = await fetchApi<
|
|
4
|
+
const data = await fetchApi<ListItem[]>('/zhihu');
|
|
5
5
|
return ['🔥 知乎热榜', '', formatList(data, args.limit || 10)].join('\n');
|
|
6
6
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,44 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* 功能列表:
|
|
11
|
-
* 60s新闻 · 天气 · 微博热搜 · 知乎热榜 · 抖音热搜 · 头条热搜
|
|
12
|
-
* 一言 · 摸鱼日历 · IP查询 · Bing壁纸 · 金价 · 油价
|
|
13
|
-
* 汇率 · 翻译 · 历史上的今天 · KFC文案 · 段子
|
|
14
|
-
*
|
|
15
|
-
* 所有工具定义在 tools/ 目录下,框架自动发现注册。
|
|
16
|
-
*
|
|
17
|
-
* 配置方式(zhin.config.yml):
|
|
18
|
-
* ```yaml
|
|
19
|
-
* plugins:
|
|
20
|
-
* 60s:
|
|
21
|
-
* apiBase: https://60s.viki.moe
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
import { usePlugin } from 'zhin.js';
|
|
25
|
-
|
|
26
|
-
const plugin = usePlugin();
|
|
27
|
-
const { logger, root } = plugin;
|
|
28
|
-
|
|
29
|
-
// ─── 配置 ────────────────────────────────────────────────────────────────────
|
|
30
|
-
|
|
31
|
-
interface Config {
|
|
32
|
-
apiBase?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const configService = root.inject('config');
|
|
36
|
-
const appConfig = configService?.getPrimary<{ '60s'?: Config }>() || {};
|
|
37
|
-
const config: Config = {
|
|
38
|
-
apiBase: 'https://60s.viki.moe',
|
|
39
|
-
...appConfig['60s'],
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// 将 API 地址写入环境变量,供 tool handler 使用
|
|
43
|
-
process.env.ZHIN_60S_API = config.apiBase || 'https://60s.viki.moe';
|
|
44
|
-
|
|
1
|
+
export {
|
|
2
|
+
asArray,
|
|
3
|
+
asRecord,
|
|
4
|
+
asString,
|
|
5
|
+
fetchApi,
|
|
6
|
+
formatList,
|
|
7
|
+
} from './api.js';
|
|
8
|
+
export type { ApiPayload, ListItem } from './api.js';
|
package/lib/index.d.ts
DELETED
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/plugin.yml
DELETED
package/tools/api.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 60s API 共享模块 — 供 *.tool.md handler 使用
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const API_BASE = process.env.ZHIN_60S_API || 'https://60s.viki.moe';
|
|
6
|
-
|
|
7
|
-
export async function fetchApi<T = any>(
|
|
8
|
-
endpoint: string,
|
|
9
|
-
params?: Record<string, string>,
|
|
10
|
-
): Promise<T> {
|
|
11
|
-
const url = new URL(`${API_BASE}/v2${endpoint}`);
|
|
12
|
-
if (params) {
|
|
13
|
-
Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));
|
|
14
|
-
}
|
|
15
|
-
const res = await fetch(url.toString());
|
|
16
|
-
const data = (await res.json()) as any;
|
|
17
|
-
if (data.error) throw new Error(data.error);
|
|
18
|
-
if (data.code !== undefined && data.code !== 200 && data.code !== 0) {
|
|
19
|
-
throw new Error(data.message || data.msg || `API 错误: ${data.code}`);
|
|
20
|
-
}
|
|
21
|
-
return data.data ?? data;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function formatList(items: any[], limit = 10): string {
|
|
25
|
-
return items
|
|
26
|
-
.slice(0, limit)
|
|
27
|
-
.map((item, i) => {
|
|
28
|
-
const title = item.title || item.name || item.word || item;
|
|
29
|
-
const hot = item.hot_value || item.hot;
|
|
30
|
-
const hotStr = hot ? ` 🔥${hot}` : '';
|
|
31
|
-
return `${i + 1}. ${title}${hotStr}`;
|
|
32
|
-
})
|
|
33
|
-
.join('\n');
|
|
34
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: exchange_rate
|
|
3
|
-
description: 查询货币汇率
|
|
4
|
-
tags: [金融, 汇率, 查询]
|
|
5
|
-
keywords: [汇率, 兑换, 外汇, exchange, rate]
|
|
6
|
-
parameters:
|
|
7
|
-
from:
|
|
8
|
-
type: string
|
|
9
|
-
description: 源货币,如 USD, EUR, JPY
|
|
10
|
-
to:
|
|
11
|
-
type: string
|
|
12
|
-
description: 目标货币,如 CNY
|
|
13
|
-
handler: ./handler.ts
|
|
14
|
-
---
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { fetchApi } from '../api.js';
|
|
2
|
-
|
|
3
|
-
export default async function () {
|
|
4
|
-
const data = await fetchApi<any>('/today-in-history');
|
|
5
|
-
const dateStr = data.date || `${data.month || ''}月${data.day || ''}日`;
|
|
6
|
-
const lines = [`📅 历史上的今天 (${dateStr})`, ''];
|
|
7
|
-
const items = data.items || (Array.isArray(data) ? data : []);
|
|
8
|
-
items.slice(0, 10).forEach((item: any, i: number) => {
|
|
9
|
-
const year = item.year || '';
|
|
10
|
-
const title = item.title || item.event || item.content || item;
|
|
11
|
-
const typeIcon = item.event_type === 'birth' ? '👶' : item.event_type === 'death' ? '🕊️' : '📌';
|
|
12
|
-
lines.push(`${typeIcon} ${i + 1}. ${year ? `[${year}] ` : ''}${title}`);
|
|
13
|
-
});
|
|
14
|
-
return lines.join('\n');
|
|
15
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: hitokoto
|
|
3
|
-
description: 获取一言/每日一句,随机返回一条语句
|
|
4
|
-
tags: [语录, 文学, 随机]
|
|
5
|
-
keywords: [一言, 每日一句, 语录, 名言, hitokoto]
|
|
6
|
-
preExecutable: true
|
|
7
|
-
parameters:
|
|
8
|
-
type:
|
|
9
|
-
type: string
|
|
10
|
-
description: "类型:a=动画, b=漫画, c=游戏, d=文学, e=原创, f=网络, g=其他, h=影视, i=诗词, j=网易云, k=哲学, l=抖机灵"
|
|
11
|
-
handler: ./handler.ts
|
|
12
|
-
---
|
package/tools/kfc/kfc.tool.md
DELETED
package/tools/moyu/handler.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { fetchApi } from '../api.js';
|
|
2
|
-
|
|
3
|
-
export default async function () {
|
|
4
|
-
const data = await fetchApi<any>('/moyu');
|
|
5
|
-
if (typeof data === 'string') return `🐟 摸鱼日历\n\n${data}`;
|
|
6
|
-
const lines = ['🐟 摸鱼日历', ''];
|
|
7
|
-
if (data.date?.gregorian) lines.push(`📅 ${data.date.gregorian} ${data.date.weekday || ''}`);
|
|
8
|
-
if (data.date?.lunar) {
|
|
9
|
-
const l = data.date.lunar;
|
|
10
|
-
lines.push(`🌙 农历${l.monthCN || ''}${l.dayCN || ''} ${l.yearGanZhi || ''}年`);
|
|
11
|
-
}
|
|
12
|
-
if (data.today) {
|
|
13
|
-
const t = data.today;
|
|
14
|
-
if (t.holidayName) lines.push(`🎉 ${t.holidayName}`);
|
|
15
|
-
if (t.solarTerm) lines.push(`🌿 ${t.solarTerm}`);
|
|
16
|
-
lines.push(t.isWorkday ? '💼 今天是工作日' : '🎮 今天不上班');
|
|
17
|
-
}
|
|
18
|
-
if (data.festivals && Array.isArray(data.festivals)) {
|
|
19
|
-
data.festivals.forEach((f: any) => lines.push(`🎊 ${f.name || f}`));
|
|
20
|
-
}
|
|
21
|
-
if (data.countdown && Array.isArray(data.countdown)) {
|
|
22
|
-
lines.push('');
|
|
23
|
-
data.countdown.forEach((c: any) => {
|
|
24
|
-
if (c.name && c.days !== undefined) lines.push(`⏳ 距 ${c.name} 还有 ${c.days} 天`);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return lines.join('\n');
|
|
28
|
-
}
|
package/tools/moyu/moyu.tool.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { fetchApi } from '../api.js';
|
|
2
|
-
|
|
3
|
-
export default async function (args: { text: string; to?: string }) {
|
|
4
|
-
const params: Record<string, string> = { text: args.text };
|
|
5
|
-
if (args.to) params.to = args.to;
|
|
6
|
-
const data = await fetchApi<any>('/fanyi', params);
|
|
7
|
-
const srcText = data.source?.text || args.text;
|
|
8
|
-
const srcLang = data.source?.type_desc || data.source?.type || '';
|
|
9
|
-
const tgtText = data.target?.text || data.result || data.translation || (typeof data === 'string' ? data : '');
|
|
10
|
-
const tgtLang = data.target?.type_desc || data.target?.type || '';
|
|
11
|
-
const lines = [
|
|
12
|
-
'🌐 翻译结果',
|
|
13
|
-
'',
|
|
14
|
-
`原文${srcLang ? ` (${srcLang})` : ''}: ${srcText}`,
|
|
15
|
-
`译文${tgtLang ? ` (${tgtLang})` : ''}: ${tgtText}`,
|
|
16
|
-
];
|
|
17
|
-
if (data.target?.pronounce) lines.push(`发音: ${data.target.pronounce}`);
|
|
18
|
-
return lines.join('\n');
|
|
19
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: translate_60s
|
|
3
|
-
description: 翻译文本
|
|
4
|
-
tags: [工具, 翻译, 语言]
|
|
5
|
-
keywords: [翻译, 英文, 中文, 日文, translate, 译]
|
|
6
|
-
parameters:
|
|
7
|
-
text:
|
|
8
|
-
type: string
|
|
9
|
-
description: 要翻译的文本
|
|
10
|
-
required: true
|
|
11
|
-
to:
|
|
12
|
-
type: string
|
|
13
|
-
description: 目标语言,如 en, zh, ja
|
|
14
|
-
handler: ./handler.ts
|
|
15
|
-
---
|
package/tools/weather/handler.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { fetchApi } from '../api.js';
|
|
2
|
-
|
|
3
|
-
export default async function (args: { city: string }) {
|
|
4
|
-
const data = await fetchApi<any>('/weather', { query: args.city });
|
|
5
|
-
const w = data.weather;
|
|
6
|
-
const aq = data.air_quality;
|
|
7
|
-
const loc = data.location;
|
|
8
|
-
const cityName = loc?.city || loc?.name || args.city;
|
|
9
|
-
const lines = [
|
|
10
|
-
`🌤️ ${cityName} 天气`,
|
|
11
|
-
'',
|
|
12
|
-
`🌡️ 温度: ${w.temperature}°C`,
|
|
13
|
-
`☁️ 天气: ${w.condition}`,
|
|
14
|
-
`💧 湿度: ${w.humidity}%`,
|
|
15
|
-
`💨 风: ${w.wind_direction} ${w.wind_power}`,
|
|
16
|
-
];
|
|
17
|
-
if (aq) {
|
|
18
|
-
const quality = aq.quality || '';
|
|
19
|
-
lines.push(`🌬️ 空气: ${quality}${aq.aqi ? ` (AQI ${aq.aqi})` : ''}`);
|
|
20
|
-
}
|
|
21
|
-
return lines.join('\n');
|
|
22
|
-
}
|
|
File without changes
|