| Total Complexity | 4 |
| Total Lines | 18 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import time |
||
| 7 | class AntiSpam(object): |
||
| 8 | |||
| 9 | def __init__(self): |
||
| 10 | self.spammed = 0 |
||
| 11 | self.info = {} |
||
| 12 | |||
| 13 | def check_spam(self, json_message): |
||
| 14 | message_length = len(json_message) |
||
| 15 | info_key = int(round(time.time() * 100)) |
||
| 16 | self.info[info_key] = message_length |
||
| 17 | if message_length > settings.MAX_MESSAGE_SIZE: |
||
| 18 | self.spammed += 1 |
||
| 19 | raise ValidationError("Message can't exceed %d symbols" % settings.MAX_MESSAGE_SIZE) |
||
| 20 | self.check_timed_spam() |
||
| 21 | |||
| 22 | def check_timed_spam(self): |
||
| 23 | # TODO implement me |
||
| 24 | pass |
||
| 25 | # raise ValidationError("You're chatting too much, calm down a bit!") |