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

Method handleAffCommand

aff/aff.ts:111–164  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

109 if (!this.db) return;
110 const text = msg.text || "";
111 const parts = text.trim().split(/\s+/);
112 const subCommand = parts[1]?.toLowerCase();
113 const param = parts[2];
114
115 // 1. 无参数:智能发送
116 if (!subCommand) {
117 await this.handleSmartSend(msg);
118 return;
119 }
120
121 // 2. 数字参数:发送指定序号
122 const index = parseInt(subCommand);
123 if (!isNaN(index)) {
124 await this.sendAffByIndex(msg, index);
125 return;
126 }
127
128 // 3. 保存命令
129 if (subCommand === "save") {
130 await this.saveAffInfo(msg);
131 return;
132 }
133
134 // 4. 列表命令
135 if (subCommand === "list") {
136 await this.listAffs(msg);
137 return;
138 }
139
140 // 5. 删除命令
141 if (subCommand === "remove" || subCommand === "rm" || subCommand === "del") {
142 await this.handleRemove(msg, param);
143 return;
144 }
145
146 // 无效参数
147 await msg.edit({
148 text: "❌ <b>无效的参数</b>\n\n" +
149 "💡 使用方法:\n" +
150 `• <code>${mainPrefix}aff</code> - 发送/列表\n` +
151 `• <code>${mainPrefix}aff &lt;序号&gt;</code> - 发送指定条目\n` +
152 `• <code>${mainPrefix}aff save</code> - 保存回复\n` +
153 `• <code>${mainPrefix}aff remove &lt;序号&gt;</code> - 删除条目`,
154 parseMode: "html"
155 });
156
157 } catch (error: any) {
158 await this.handleError(msg, error);
159 }
160 }
161
162 // 智能发送:1条直接发,多条显示列表,0条提示保存
163 private async handleSmartSend(msg: Api.Message): Promise<void> {
164 const affs = await this.getAffs();
165
166 if (affs.length === 0) {
167 await msg.edit({

Callers

nothing calls this directly

Calls 7

handleSmartSendMethod · 0.95
sendAffByIndexMethod · 0.95
saveAffInfoMethod · 0.95
listAffsMethod · 0.95
handleRemoveMethod · 0.95
handleErrorMethod · 0.95
editMethod · 0.45

Tested by

no test coverage detected