MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / setTarget

Method setTarget

ssh/ssh.ts:1376–1415  ·  view source on GitHub ↗
(msg: Api.Message, target: string)

Source from the content-addressed store, hash-verified

1374 }
1375
1376 await msg.edit({
1377 text: `✅ <b>端口 ${port} 已关闭</b>\n\n协议: TCP/UDP\n\n💡 提示: 规则已添加到iptables,重启后可能需要重新设置`,
1378 parseMode: "html"
1379 });
1380 } catch (error: any) {
1381 throw new Error(`关闭端口失败: ${error.message}`);
1382 }
1383 }
1384
1385 // 设置接收目标
1386 private async setTarget(msg: Api.Message, target: string): Promise<void> {
1387 if (!target) {
1388 await msg.edit({
1389 text: `❌ <b>请提供目标</b>\n\n示例:\n<code>${mainPrefix}ssh set me</code> - 重置为默认发送到收藏夹\n<code>${mainPrefix}ssh set @username</code> - 设置发送到指定用户\n<code>${mainPrefix}ssh set -1001234567890</code> - 设置发送到指定群组/频道`,
1390 parseMode: "html"
1391 });
1392 return;
1393 }
1394
1395 await msg.edit({ text: `🔄 正在设置接收目标为: ${htmlEscape(target)}...`, parseMode: "html" });
1396
1397 try {
1398 // 验证目标是否有效
1399 if (target !== "me") {
1400 const client = await getGlobalClient();
1401 if (client) {
1402 try {
1403 await client.getEntity(target);
1404 } catch {
1405 await msg.edit({
1406 text: `⚠️ <b>无法验证目标有效性</b>\n\n目标 <code>${htmlEscape(target)}</code> 可能无效,但配置已保存。\n\n发送时如果失败将自动使用收藏夹。`,
1407 parseMode: "html"
1408 });
1409 await ConfigManager.set(CONFIG_KEYS.TARGET_CHAT, target);
1410 return;
1411 }
1412 }
1413 }
1414
1415 // 保存配置
1416 await ConfigManager.set(CONFIG_KEYS.TARGET_CHAT, target);
1417
1418 await msg.edit({

Callers 1

handleSSHMethod · 0.95

Calls 3

htmlEscapeFunction · 0.70
editMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected