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

Function dme

dme/dme.ts:1249–1422  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

1247
1248 // 标准参数解析
1249 const lines = msg.text?.trim()?.split(/\r?\n/g) || [];
1250 const parts = lines?.[0]?.split(/\s+/) || [];
1251 const [, ...args] = parts;
1252 const sub = (args[0] || "").toLowerCase();
1253
1254 try {
1255 // 无参数时显示帮助
1256 if (!sub) {
1257 await msg.edit({
1258 text: help_text,
1259 parseMode: "html"
1260 });
1261 return;
1262 }
1263
1264 // 处理 help 命令
1265 if (sub === "help" || sub === "h") {
1266 await msg.edit({
1267 text: help_text,
1268 parseMode: "html"
1269 });
1270 return;
1271 }
1272
1273 // 检查是否为防撤回模式 (-f 参数)
1274 const isAntiRecallMode = sub === "-f";
1275 let userRequestedCount: number;
1276
1277 if (isAntiRecallMode) {
1278 // -f 模式,数量在第二个参数
1279 const countArg = args[1];
1280 if (!countArg) {
1281 await msg.edit({
1282 text: `❌ <b>参数错误:</b> 请指定删除数量\n\n💡 使用 <code>${mainPrefix}dme -f [数量]</code>`,
1283 parseMode: "html"
1284 });
1285 return;
1286 }
1287 userRequestedCount = parseInt(countArg);
1288 } else {
1289 // 普通模式,数量在第一个参数
1290 userRequestedCount = parseInt(sub);
1291 }
1292
1293 if (isNaN(userRequestedCount) || userRequestedCount <= 0) {
1294 await msg.edit({
1295 text: `❌ <b>参数错误:</b> 删除数量必须为正整数\n\n💡 使用 <code>${mainPrefix}dme [数量]</code> 或 <code>${mainPrefix}dme -f [数量]</code>`,
1296 parseMode: "html"
1297 });
1298 return;
1299 }
1300
1301 const requestedTotalCount = userRequestedCount;
1302 const shouldRunInRounds =
1303 requestedTotalCount !== CONFIG.UNLIMITED_REQUEST_COUNT &&
1304 requestedTotalCount > CONFIG.MAX_SAFE_REQUEST_COUNT;
1305
1306 if (shouldRunInRounds) {

Callers

nothing calls this directly

Calls 6

runOneRoundFunction · 0.85
errorMethod · 0.80
sleepFunction · 0.70
htmlEscapeFunction · 0.70
editMethod · 0.45

Tested by

no test coverage detected