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

Method isMessageMatching

search/search.ts:643–656  ·  view source on GitHub ↗
(message: Api.Message, query: string)

Source from the content-addressed store, hash-verified

641 }
642
643 private isMessageMatching(message: Api.Message, query: string): boolean {
644 const normalizedQuery = this.normalizeSearchTerm(query);
645 const textSources = [message.text, message.message];
646 const fileNameAttr = message.video?.attributes.find((attr: any): attr is Api.DocumentAttributeFilename => attr instanceof Api.DocumentAttributeFilename);
647 if (fileNameAttr?.fileName) textSources.push(fileNameAttr.fileName);
648
649 for (const source of textSources) {
650 if (source) {
651 const normalizedText = this.normalizeSearchTerm(source);
652 if (this.fuzzyMatch(normalizedText, normalizedQuery)) return true;
653 }
654 }
655 return false;
656 }
657
658 private normalizeSearchTerm(text: string): string {
659 return text.toLowerCase().replace(/[-_\s\.\|\\\/#]+/g, ' ').replace(/\s+/g, ' ').trim();

Callers 2

findAndSendVideoMethod · 0.95

Calls 2

normalizeSearchTermMethod · 0.95
fuzzyMatchMethod · 0.95

Tested by

no test coverage detected