123456789101112131415161718 |
- from math import floor
- from million.model.message import Message
-
- # TODO WIP
- # - DNS to resolve audio, gif, pictures with counts
- def compute(msg: Message) -> int:
- """ Returns the estimated value counted in this message
- """
- value = None
- # Remove any number that is not a digit
- # TODO parse potential math expressions in content
- cleaned_content = ''.join([c for c in msg.content if c.isdigit()])
- try:
- value = floor(float(cleaned_content))
- except Exception as e:
- raise ValueError(
- f"Message {cleaned_content} does not contain a number ({e})")
- return value
|