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.

word_finder.py 380B

1234567891011
  1. import re
  2. from typing import List
  3. from million.model.message import Message
  4. def _wordFilter(msg: Message, words: List[str]) -> bool:
  5. rgx = r"(\b"+ r'\b|\b'.join(words) + r"\b)"
  6. return msg.content and re.search(rgx, msg.content, re.I)
  7. def findWords(messages: List[Message], words: List[str]) -> List[Message]:
  8. return filter(lambda m: _wordFilter(m, words), messages)