您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

retain_counts.py 462B

123456789101112131415161718192021
  1. import re
  2. from typing import List
  3. from million.model.message import Message
  4. def is_count(message: Message) -> bool:
  5. """
  6. Check if the message is a count
  7. """
  8. return message.content is not None and bool(re.search('(\d{2,}|^\d$)', message.content))
  9. def retain_counts(messages: List[Message]) -> List[Message]:
  10. """
  11. Retain only the messages that have a content
  12. """
  13. return [
  14. m for m in messages
  15. if is_count(m)
  16. ]