Merge branch 'frost' of https://github.com/Aevann1/rDrama into frost

master
Aevann1 2022-08-30 23:22:19 +02:00
commit f586fac262
2 changed files with 4 additions and 3 deletions

View File

@ -91,7 +91,8 @@ reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(reddit\.com|new\.reddit.c
color_regex = re.compile("[a-z0-9]{6}", flags=re.A)
showmore_regex = re.compile("(.{3000,40000}?</p>)(<p>.*)", flags=re.A)
# lazy match on the {}?, only match if there is trailing text
showmore_regex = re.compile("^(.{3000,40000}?</p>)(<p>.*)", flags=re.A)
search_token_regex = re.compile('"([^"]*)"|(\S+)', flags=re.A)
@ -145,4 +146,4 @@ def command_regex_matcher(match, upper=False):
if match.group(2) == 'roll':
color = tuple(choices(range(256), k=3))
result = f'<b style="color:rgb{color}">Your roll: {result}</b>'
return match.group(1) + result
return match.group(1) + result

View File

@ -373,7 +373,7 @@ def sanitize(sanitized, edit=False, limit_pings=0, showmore=True):
sanitized = sanitized.replace('\n','')
if showmore and len(sanitized) > 5000:
sanitized = showmore_regex.sub(r'\1<p><button class="showmore" onclick="showmore()">SHOW MORE</button></p><d class="d-none">\2</d>', sanitized)
sanitized = showmore_regex.sub(r'\1<p><button class="showmore" onclick="showmore()">SHOW MORE</button></p><d class="d-none">\2</d>', sanitized, count=1)
return sanitized.strip()