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

Function getChatIdFromMessage

shift/shift.ts:2186–2213  ·  view source on GitHub ↗
(message: any, isEdited?: boolean)

Source from the content-addressed store, hash-verified

2184// Check if message is filtered
2185async function isMessageFiltered(
2186 message: any,
2187 sourceId: number
2188): Promise<boolean> {
2189 const rule = await getShiftRule(sourceId);
2190 if (!rule) return false;
2191
2192 if (rule.whitelistMode) {
2193 if (!rule.whitelistPatterns || rule.whitelistPatterns.length === 0) {
2194 return true;
2195 }
2196 if (!message.text) return true;
2197 const text = message.text;
2198 return !rule.whitelistPatterns.some((pattern) => {
2199 try {
2200 const regex = new RegExp(pattern, "i");
2201 return regex.test(text);
2202 } catch (e) {
2203 console.error(`[SHIFT] 无效的正则表达式: ${pattern}`, e);
2204 return false;
2205 }
2206 });
2207 }
2208
2209 const keywords = rule.filters;
2210 if (!keywords || keywords.length === 0 || !message.text) return false;
2211
2212 const text = message.text.toLowerCase();
2213 return keywords.some((keyword) => text.includes(keyword.toLowerCase()));
2214}
2215
2216// Get chat ID from message

Callers 2

getGroupKeyFunction · 0.85
handleIncomingMessageFunction · 0.85

Calls 1

ensureChannelIdFunction · 0.85

Tested by

no test coverage detected