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

Function parseChatIdentifier

sum/sum.ts:205–238  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

203
204 // 4. 尝试解析简化格式
205 const match = interval.match(/^(\d+)(h|m)$/i);
206 if (!match) {
207 console.log(`[sum] 无法解析简化格式,返回 null`);
208 return null;
209 }
210
211 const value = parseInt(match[1]);
212 const unit = match[2].toLowerCase();
213 if (value <= 0) return null;
214
215 if (unit === "h") {
216 const result = `0 0 */${value} * * *`;
217 console.log(`[sum] 简化格式(小时): "${result}"`);
218 return result;
219 } else if (unit === "m") {
220 const result = `0 */${value} * * * *`;
221 console.log(`[sum] 简化格式(分钟): "${result}"`);
222 return result;
223 }
224
225 console.log(`[sum] 未知情况,返回 null`);
226 return null;
227}
228
229function parseChatIdentifier(input: string): string {
230 // 1. 如果是纯数字或负数ID,直接返回
231 if (/^-?\d+$/.test(input)) {
232 return input;
233 }
234
235 // 2. 处理私有邀请链接 https://t.me/+xxxxx 或 https://t.me/joinchat/xxxxx
236 // 这种格式需要特殊处理,保留完整链接
237 const inviteLinkMatch = input.match(
238 /(?:https?:\/\/)?t\.me\/(?:\+|joinchat\/)([a-zA-Z0-9_-]+)/,
239 );
240 if (inviteLinkMatch) {
241 return input; // 返回完整链接,让 formatEntity 特殊处理

Callers 1

SummaryPluginClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected