You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wordFinder.py 421B

12345678910111213
  1. import re
  2. from typing import List
  3. from million.model.message import Message
  4. def _wordFilter(msg: Message, regexs: List[str]) -> bool:
  5. return msg.content and any(
  6. re.search(rgx, msg.content) for rgx in regexs
  7. )
  8. def findWords(messages: List[Message], words: List[str]) -> List[Message]:
  9. r_words = [r"\b"+word+r"\b" for word in words]
  10. return filter(lambda m: _wordFilter(m, r_words), messages)