Improve the Queen award (#156)

Fixed bugs:
 - Sometimes two people would get the same username
 - Sometimes a whole post would have the same prefix
 - Links would be broken
 - Greentext would be broken
 - strings of periods do not become "and, and, and, and,"

New stuff:
 - New girl catchphrases
 - New girl pfps
 - Catchphrases have a chance to not be applied (50%, but configurable)
 - A lot more regexes
 	- everyone => literally everyone (and others)
    - into => totally into
    - hello => hiiiiiiii (and others)
    - just => like just
    - i mean => i mean like
    - ! => !!!

Co-authored-by: Chuck Sneed <sneed@formerlychucks.net>
Reviewed-on: #156
Co-authored-by: HeyMoon <heymoon@noreply.fsdfsd.net>
Co-committed-by: HeyMoon <heymoon@noreply.fsdfsd.net>
pull/157/head
HeyMoon 2023-06-22 05:20:33 +00:00 committed by Aevann
parent a5d41a930b
commit b304d00169
22 changed files with 59 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -818,7 +818,7 @@ class User(Base):
if self.rainbow:
return f"{SITE_FULL}/e/marseysalutepride.webp"
if self.queen:
number_of_girl_pfps = 8
number_of_girl_pfps = 25
pic_num = (self.id % number_of_girl_pfps) + 1
return f"{SITE_FULL}/i/pfps/girls/{pic_num}.webp"
if self.profileurl and self.can_see_my_shit:

View File

@ -101,8 +101,11 @@ AJ_REPLACEMENTS = {
'EVERYBODY': 'EVERYPONY',
}
PHRASE_CHANCE = 0.5
GIRL_PHRASES = [
"ok so $",
"um $",
"also like $",
"literally, $",
"i feel like $",
"my heart is telling me $",
@ -112,8 +115,10 @@ GIRL_PHRASES = [
"$ and thats the tea, sis",
"$ but go off i guess",
"$ but go off",
"$, karen",
"$ but its whatever"
"$ but its whatever",
"$ and its EVERYTHING",
"$ *sips tea*",
"$ PERIODT"
]
GIRL_NAME_PREFIX = [
'the',

View File

@ -69,9 +69,20 @@ torture_regex = re.compile('(^|\s)(i|me)($|\s)', flags=re.I|re.A)
torture_regex2 = re.compile("(^|\s)(i'm)($|\s)", flags=re.I|re.A)
torture_regex3 = re.compile("(^|\s)(my|mine)($|\s)", flags=re.I|re.A)
sentence_ending_regex = re.compile('(\.)', flags=re.I|re.A)
#matches ". ", does not match "..." or a.b
sentence_ending_regex = re.compile('(?<!\.)(\.)(?=$|\n|\s)', flags=re.I|re.A)
normal_punctuation_regex = re.compile('(\"|\')', flags=re.I|re.A)
more_than_one_comma_regex = re.compile('\,\,+', flags=re.I|re.A)
#matches the various superlatives, but only if it as the start or end of a string or if it surrounded by spaces or is at the end of a word.
superlative_regex = re.compile('(?<=^|(?<=\s))(everyone|everybody|nobody|all|none|every|any|no one|anything)(?=$|\n|\s|[.?!,])', flags=re.I|re.A)
#like above, except only when totally doesn't already prefix
totally_regex = re.compile('(?<=^|(?<=\s))(?<!totally )(into)(?=$|\n|\s|[.?!,])', flags=re.I|re.A)
greeting_regex = re.compile('(?<=^|(?<=\s))(hello|hi|hey|hecko)(?=$|\n|\s|[.?!,])', flags=re.I|re.A)
like_before_regex = re.compile('(?<=^|(?<=\s))(?<!like )(just|only)(?=$|\n|\s|[.?!,])', flags=re.I|re.A)
like_after_regex = re.compile('(?<=^|(?<=\s))(i mean)(?! like)(?=$|\n|\s|[.?!,])', flags=re.I|re.A)
#match ! or ? but only if it isn't touching another ! or ?, or is in front of a letter
single_repeatable_punctuation = re.compile('(?<!!|\?)(!|\?)(?!!|\?)(?=\s|$)', flags=re.I|re.A)
initial_part_regex = re.compile('(?<=^)(>+)', flags=re.I|re.A)
image_check_regex = re.compile(f'!\[\]\(((?!(https:\/\/({hosts})\/|\/)).*?)\)', flags=re.A)

View File

@ -688,14 +688,27 @@ def torture_ap(string, username):
def torture_queen(string, key):
if not string: return string
result = initial_part_regex.search(string)
initial = result.group(1) if result else ""
string = string.lower()
string = initial_part_regex.sub("", string)
string = sentence_ending_regex.sub(", and", string)
string = superlative_regex.sub(r"literally \g<1>", string)
string = totally_regex.sub(r"totally \g<1>", string)
string = single_repeatable_punctuation.sub(r"\g<1>\g<1>\g<1>", string)
string = greeting_regex.sub(r"hiiiiiiiiii", string)
string = like_after_regex.sub(r"\g<1> like", string)
string = like_before_regex.sub(r"like \g<1>", string)
string = normal_punctuation_regex.sub("", string)
string = more_than_one_comma_regex.sub(",", string)
if string[-5:] == ', and':
string = string[:-5]
girl_phrase = GIRL_PHRASES[key%len(GIRL_PHRASES)]
string = girl_phrase.replace("$", string)
random.seed(key)
if random.random() < PHRASE_CHANCE:
girl_phrase = random.choice(GIRL_PHRASES)
string = girl_phrase.replace("$", string)
string = initial + string
return string
def torture_object(obj, torture_method):
@ -706,7 +719,7 @@ def torture_object(obj, torture_method):
i = 0
for tag in tags:
i+=1
key = obj.id*i
key = obj.id+i
tag.string.replace_with(torture_method(tag.string, key))
obj.body_html = str(soup).replace('<html><body>','').replace('</body></html>','')

View File

@ -329,12 +329,15 @@ def award_thing(v, thing_type, id):
abort(409, f"{safe_username} is under the effect of a conflicting award: OwOify award!")
if not author.queen:
adjective = GIRL_NAME_ADJECTIVE[author.id%20].capitalize()
noun = GIRL_NAME_NOUN[(int(author.id/20))%20].capitalize()
prefix = GIRL_NAME_PREFIX[(int((id/20)/20))%8]
number_of_adjectives = len(GIRL_NAME_ADJECTIVE)
number_of_nouns = len(GIRL_NAME_NOUN)
number_of_prefix = len(GIRL_NAME_PREFIX)
numbers = get_number_tuple(author.id, [number_of_adjectives, number_of_nouns, number_of_prefix])
adjective = GIRL_NAME_ADJECTIVE[numbers[0]].capitalize()
noun = GIRL_NAME_NOUN[numbers[1]].capitalize()
prefix = GIRL_NAME_PREFIX[numbers[2]]
prefix = prefix[0].upper() + prefix[1:]
number = int(((author.id/20)/20)/8)
number = numbers[3]
new_name = f"{prefix}{adjective}{noun}"+ (str(number) if number > 0 else "")
@ -551,3 +554,18 @@ def award_thing(v, thing_type, id):
return {"message": f"{AWARDS[kind]['title']} award given to {thing_type} successfully!"}
def shift_number_down(input, mod):
if input <= 0:
return 0, 0
number = (input%mod)
input -= number
input /= mod
return int(number), int(input)
def get_number_tuple(input, mods):
results = []
for mod in mods:
result, input = shift_number_down(input, mod)
results.append(result)
results.append(input)
return results