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

Function respondToCommand

tmp_admin/tmp_admin.ts:146–183  ·  view source on GitHub ↗
(
  msg: Api.Message,
  trigger: Api.Message | undefined,
  options: CommandResponse,
  ignoreNotModified?: boolean
)

Source from the content-addressed store, hash-verified

144): Promise<void> {
145 if (!trigger) {
146 if (ignoreNotModified) {
147 await editMessageIgnoringNotModified(msg, options);
148 return;
149 }
150 await msg.edit(options);
151 return;
152 }
153
154 const client = trigger.client || msg.client;
155 const peer = trigger.peerId || msg.peerId;
156 if (!client || !peer) {
157 await editMessageIgnoringNotModified(msg, options);
158 return;
159 }
160
161 const sendOptions = {
162 message: options.text,
163 ...(options.parseMode ? { parseMode: options.parseMode } : {}),
164 };
165
166 try {
167 await client.sendMessage(peer, {
168 ...sendOptions,
169 replyTo: trigger.id,
170 });
171 } catch {
172 await client.sendMessage(peer, sendOptions);
173 }
174
175 await deleteMessageQuiet(msg);
176}
177
178function parseDurationMinutes(raw?: string): number {
179 if (!raw) return defaultDurationMinutes;
180 const minutes = Number(raw);
181 if (!Number.isFinite(minutes) || minutes <= 0) {
182 throw new Error("时长必须是大于 0 的分钟数");
183 }
184 return minutes;
185}
186

Callers 4

TmpAdminPluginClass · 0.85
addTemporaryAdminMethod · 0.85
removeTemporaryAdminMethod · 0.85
listJobsMethod · 0.85

Calls 3

deleteMessageQuietFunction · 0.85
editMethod · 0.45

Tested by

no test coverage detected