Files
archived-discord-bot/api/utils.py
13xforever 258e51927d Use actual urlencode instead of html encoder (???)
Sanitize user input when showin compat search results
Truncate compat search text to 40 characters to prevent dos with giant strings
2018-03-15 18:26:47 +05:00

18 lines
369 B
Python

import time
def trim_string(string: str, length: int) -> str:
if len(string) > length:
return string[:length - 3] + "..."
else:
return string
def system_time_millis() -> int:
return int(round(time.time() * 1000))
def sanitize_string(s: str) -> str:
return s.replace("`", "`\u200d").replace("@", "@\u200d") if s is not None else s