import re from .config.const import * tranny = f':marseytrain:' trannie = f':!marseytrain:' troon = f':marseytrain2:' def replace_train_html(body): body = body.replace(tranny, ':marseytrain:') body = body.replace(trannie, ':!marseytrain:') body = body.replace(troon, ':marseytrain2:') return body trans_valid_copypasta = """You are a real woman. You have no womb, you have no ovaries, you have no eggs, but that doesn't matter. You are a valid human who is trying to feel comfortable in her body. All the “validation” you get is pure. Behind your back people love you. Your parents are happy and proud of you, your friends laugh at your jokes behind closed doors, and boys love you, and girls envy you. Men absolutely love you. Trans folk who “pass” look ordinary and natural to a man. Your bone structure does not matter. Estradiol widens the hips. You will be happy. You will smile every single morning and tell yourself it’s going to be ok, and deep inside you feel the euphoria creeping up like a weed. It is what defines you, not the transphobes. Eventually, it’ll be perfect for you - you’ll come out, start HRT, get top surgery, and finally be your ideal self. Your parents will find you, happy and relieved that they finally have a happy daughter. They’ll congratulate you on your hard journey, and every passerby for the rest of eternity will know a woman is what you are.""" SLURS = { "tranny": tranny, "trannie": trannie, "troon": troon, "(?]*>|{slur_single_words}", flags=re.I|re.A) profanity_regex = re.compile(f"<[^>]*>|{profanity_single_words}", flags=re.I|re.A) SLURS_FOR_REPLACING = {} for k, val in SLURS.items(): newkey = k.split('(?!')[0] if ')' in newkey: newkey = newkey.split(')')[1] SLURS_FOR_REPLACING[newkey] = val PROFANITIES_FOR_REPLACING = {} for k, val in PROFANITIES.items(): newkey = k.split('(?!')[0] if ')' in newkey: newkey = newkey.split(')')[1] PROFANITIES_FOR_REPLACING[newkey] = val def sub_matcher(match, X_FOR_REPLACING): group_num = 0 match_str = match.group(group_num) if match_str.startswith('<'): return match_str else: repl = X_FOR_REPLACING[match_str.lower()] if "' in body or '' in body: return body if not logged_user or logged_user == 'chat' or logged_user.slurreplacer: body = slur_regex.sub(sub_matcher_slurs, body) if SITE_NAME == 'rDrama': if not logged_user or logged_user == 'chat' or logged_user.profanityreplacer: body = profanity_regex.sub(sub_matcher_profanities, body) return body