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

Function speedtest

speedtest/speedtest.ts:1055–1511  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

1053 const command = args[0] || "";
1054 const useSystem = flags.includes('--system') || flags.includes('-s');
1055
1056 try {
1057 if (command === "list") {
1058 await msg.edit({ text: "🔍 正在获取服务器列表...", parseMode: "html" });
1059
1060 const servers = await getAllServers();
1061 if (servers.length === 0) {
1062 await msg.edit({
1063 text: "❌ <b>错误</b>\n\n无可用服务器",
1064 parseMode: "html",
1065 });
1066 return;
1067 }
1068
1069 const serverList = servers
1070 .slice(0, 20)
1071 .map(
1072 (server) =>
1073 `<code>${server.id}</code> - <code>${htmlEscape(
1074 server.name
1075 )}</code> - <code>${htmlEscape(server.location)}</code>`
1076 )
1077 .join("\n");
1078
1079 await msg.edit({
1080 text: `<blockquote><b>⚡️SPEEDTEST by OOKLA</b></blockquote>\n${serverList}`,
1081 parseMode: "html",
1082 });
1083 } else if (command === "set") {
1084 const serverId = parseInt(args[1]);
1085 if (!serverId || isNaN(serverId)) {
1086 await msg.edit({
1087 text: "❌ <b>参数错误</b>\n\n请指定有效的服务器ID\n例: <code>s set 12345</code>",
1088 parseMode: "html",
1089 });
1090 return;
1091 }
1092
1093 saveDefaultServer(serverId);
1094 await msg.edit({
1095 text: `<blockquote><b>⚡️SPEEDTEST by OOKLA</b></blockquote>\n<code>默认服务器已设置为 ${serverId}</code>`,
1096 parseMode: "html",
1097 });
1098 } else if (command === "clear") {
1099 removeDefaultServer();
1100 await msg.edit({
1101 text: "<blockquote><b>⚡️SPEEDTEST by OOKLA</b></blockquote>\n<code>默认服务器已清除</code>",
1102 parseMode: "html",
1103 });
1104 } else if (command === "config") {
1105 const defaultServer = getDefaultServer() || "Auto";
1106 const typePref = getPreferredType() || "默认(photo→sticker→file→txt)";
1107 await msg.edit({
1108 text: `<blockquote><b>⚡️SPEEDTEST by OOKLA</b></blockquote>\n<code>默认服务器: ${htmlEscape(String(defaultServer))}</code>\n<code>优先类型: ${htmlEscape(typePref)}</code>\n<code>Speedtest® CLI: ${SPEEDTEST_VERSION}</code>`,
1109 parseMode: "html",
1110 });
1111 } else if (command === "type") {
1112 const t = (args[1] || "").toLowerCase();

Callers

nothing calls this directly

Calls 15

getAllServersFunction · 0.85
saveDefaultServerFunction · 0.85
removeDefaultServerFunction · 0.85
getDefaultServerFunction · 0.85
getPreferredTypeFunction · 0.85
savePreferredTypeFunction · 0.85
getMessageOrderFunction · 0.85
checkNetworkConnectivityFunction · 0.85
testServerAvailabilityFunction · 0.85
autoFixSpeedtestFunction · 0.85
runSpeedtestFunction · 0.85

Tested by

no test coverage detected