forked from rDrama/rDrama
much better poll system
parent
3a436d65ab
commit
ee55030480
|
@ -567,7 +567,8 @@ def process_poll_options(v:User, target:Union[Post, Comment]):
|
||||||
option_objects = []
|
option_objects = []
|
||||||
|
|
||||||
for pattern, exclusive in patterns:
|
for pattern, exclusive in patterns:
|
||||||
for i in pattern.finditer(target.body):
|
body_html = target.body_html.replace('&', '&')
|
||||||
|
for i in pattern.finditer(body_html):
|
||||||
option_count += 1
|
option_count += 1
|
||||||
|
|
||||||
if option_count > POLL_MAX_OPTIONS:
|
if option_count > POLL_MAX_OPTIONS:
|
||||||
|
@ -583,18 +584,16 @@ def process_poll_options(v:User, target:Union[Post, Comment]):
|
||||||
else:
|
else:
|
||||||
cls = CommentOption
|
cls = CommentOption
|
||||||
|
|
||||||
body_html=filter_emojis_only(body, strip=False) #dont strip cuz ppl sometimes leave spaces before && or after it, which breaks the replacing logic
|
|
||||||
|
|
||||||
existing = g.db.query(cls).filter_by(
|
existing = g.db.query(cls).filter_by(
|
||||||
parent_id=target.id,
|
parent_id=target.id,
|
||||||
body_html=body_html,
|
body_html=body,
|
||||||
exclusive=exclusive,
|
exclusive=exclusive,
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
if not existing:
|
if not existing:
|
||||||
option = cls(
|
option = cls(
|
||||||
parent_id=target.id,
|
parent_id=target.id,
|
||||||
body_html=body_html,
|
body_html=body,
|
||||||
exclusive=exclusive,
|
exclusive=exclusive,
|
||||||
)
|
)
|
||||||
option_objects.append(option) #shitty hack to bypass autoflush
|
option_objects.append(option) #shitty hack to bypass autoflush
|
||||||
|
|
|
@ -9,8 +9,8 @@ NOT_IN_CODE_OR_LINKS = '(?!([^<]*<\/(code|pre|a)>|[^`\n]*`|(.|\n)*```))'
|
||||||
|
|
||||||
valid_username_regex = re.compile("^[\w\-]{3,25}$", flags=re.A)
|
valid_username_regex = re.compile("^[\w\-]{3,25}$", flags=re.A)
|
||||||
|
|
||||||
mention_regex = re.compile('(?<![/;$#])@([\w\-]{1,30})' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
mention_regex = re.compile('(?<!/)@([\w\-]{1,30})' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
||||||
group_mention_regex = re.compile('(?<![/;$#])!([\w\-]{3,25})' + NOT_IN_CODE_OR_LINKS, flags=re.A|re.I)
|
group_mention_regex = re.compile('(?<!/)!([\w\-]{3,25})' + NOT_IN_CODE_OR_LINKS, flags=re.A|re.I)
|
||||||
|
|
||||||
everyone_regex = re.compile('(^|\s|>)!(everyone)' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
everyone_regex = re.compile('(^|\s|>)!(everyone)' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@ valid_sub_regex = re.compile("^[\w\-]{3,25}$", flags=re.A)
|
||||||
|
|
||||||
query_regex = re.compile("(\w+):(\S+)", flags=re.A)
|
query_regex = re.compile("(\w+):(\S+)", flags=re.A)
|
||||||
|
|
||||||
poll_regex = re.compile("(^|\n)\$\$([^\$\n]+)\$\$\s*?" + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
poll_regex = re.compile("(^|\n|>)\$\$([^\$\n]+)\$\$\s*?" + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
||||||
bet_regex = re.compile("(^|\n)##([^#\n]+)##\s*?" + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
bet_regex = re.compile("(^|\n|>)##([^#\n]+)##\s*?" + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
||||||
choice_regex = re.compile("(^|\n)&&([^&\n]+)&&\s*?" + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
choice_regex = re.compile("(^|\n|>)&&([^&\n]+)&&\s*?" + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
||||||
|
|
||||||
html_comment_regex = re.compile("<!--.*-->", flags=re.A)
|
html_comment_regex = re.compile("<!--.*-->", flags=re.A)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue