(message: Api.Message, query: string)
| 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(); |
no test coverage detected