MarseyWorld/files/helpers/marsify.py

23 lines
513 B
Python
Raw 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
2024-04-05 09:23:04 +00:00
def marsify(text, chud_phrase, seed):
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-04-05 09:23:04 +00:00
random.seed(seed)
2024-02-21 20:08:33 +00:00
marsey = random.choice(MARSEY_MAPPINGS[x])
2024-04-05 09:23:04 +00:00
random.seed()
2022-08-30 12:11:05 +00:00
new_text += f':{marsey}: '
return new_text