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

Method handleAddRule

autodelcmd/autodelcmd.ts:845–972  ·  view source on GitHub ↗
(msg: Api.Message, args: string[])

Source from the content-addressed store, hash-verified

843 await msg.edit({
844 text: `❌ 参数不足\n用法: <code>${mainPrefix}autodelcmd add [命令] [延迟秒数] [参数...] [-r] [-e]</code>\n\n` +
845 `示例:\n` +
846 `• <code>${mainPrefix}autodelcmd add ping 30</code> - ping命令30秒删除(包含带参数的)\n` +
847 `• <code>${mainPrefix}autodelcmd add ping 30 -e</code> - 🎯只有无参数的ping命令30秒删除\n` +
848 `• <code>${mainPrefix}autodelcmd add speedtest 60 -r</code> - speedtest命令60秒删除(🔄含响应)\n` +
849 `• <code>${mainPrefix}autodelcmd add tpm 60 list ls search -r</code> - tpm list/ls/search任一命令60秒删除(🔄含响应)`,
850 parseMode: "html"
851 });
852 return;
853 }
854
855 // 检查标志参数
856 const responseFlags = ['-r', '--response'];
857 const exactFlags = ['-e', '--exact'];
858 let deleteResponse = false;
859 let exactMatch = false;
860 let filteredArgs = [...args];
861
862 // 从参数中移除响应标志
863 for (const flag of responseFlags) {
864 const index = filteredArgs.indexOf(flag);
865 if (index !== -1) {
866 deleteResponse = true;
867 filteredArgs.splice(index, 1);
868 }
869 }
870
871 // 从参数中移除精确匹配标志
872 for (const flag of exactFlags) {
873 const index = filteredArgs.indexOf(flag);
874 if (index !== -1) {
875 exactMatch = true;
876 filteredArgs.splice(index, 1);
877 }
878 }
879
880 if (filteredArgs.length < 2) {
881 await msg.edit({ text: "❌ 移除标志后参数不足", parseMode: "html" });
882 return;
883 }
884
885 const command = filteredArgs[0];
886 const delay = parseInt(filteredArgs[1]);
887 const parameters = filteredArgs.slice(2);
888
889 if (isNaN(delay) || delay < 1) {
890 await msg.edit({ text: "❌ 延迟时间必须是正整数(秒)", parseMode: "html" });
891 return;
892 }
893
894 // 检查精确匹配标志与参数的冲突
895 if (exactMatch && parameters.length > 0) {
896 await msg.edit({
897 text: "❌ 精确匹配模式(-e/--exact)不能与参数同时使用\n精确匹配专用于只匹配无参数的命令调用",
898 parseMode: "html"
899 });
900 return;
901 }
902

Callers 1

AutoDeletePluginClass · 0.95

Calls 4

addCustomRuleMethod · 0.80
getCustomRulesMethod · 0.80
htmlEscapeFunction · 0.70
editMethod · 0.45

Tested by

no test coverage detected