rDrama/files/helpers/marsify.py

21 lines
469 B
Python
Raw Permalink Normal View History

2024-02-21 20:08:33 +00:00
import random
2022-08-27 02:57:19 +00:00
2023-09-29 01:29:14 +00:00
from .const_stateful import MARSEY_MAPPINGS
def marsify(text, chud_phrase):
2023-08-15 20:17:41 +00:00
if '`' in text or '<pre>' in text or '<code>' in text:
return text
2023-10-13 18:49:21 +00:00
chud_words = chud_phrase.split() if chud_phrase else []
2022-08-30 12:11:05 +00:00
new_text = ''
for x in text.split(' '):
new_text += f'{x} '
2022-09-01 22:38:33 +00:00
x = x.lower()
if x in chud_words: continue
2023-09-29 01:29:14 +00:00
if len(x) >= 5 and x in MARSEY_MAPPINGS:
2024-02-21 20:08:33 +00:00
marsey = random.choice(MARSEY_MAPPINGS[x])
2022-08-30 12:11:05 +00:00
new_text += f':{marsey}: '
return new_text