diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py
index f97298d456..454ab915b5 100644
--- a/files/helpers/sanitize.py
+++ b/files/helpers/sanitize.py
@@ -260,6 +260,15 @@ def find_all_emote_endings(word):
is_non_ending_found = True
+ if word.endswith('random'):
+ kind = word.split('random')[0].title()
+ if kind == 'Donkeykong': kind = 'Donkey Kong'
+ elif kind == 'Marseyflag': kind = 'Marsey Flags'
+ elif kind == 'Marseyalphabet': kind = 'Marsey Alphabet'
+
+ if kind in EMOJI_KINDS:
+ word = g.db.query(Emoji.name).filter_by(kind=kind).order_by(func.random()).first()[0]
+
return endings, word
@@ -282,16 +291,6 @@ def render_emoji(html, regexp, golden, emojis_used, b=False, is_title=False):
old = emoji
emoji = emoji.replace('!','').replace('#','')
- if emoji.endswith('random'):
- kind = emoji.split('random')[0].title()
- if kind == 'Donkeykong': kind = 'Donkey Kong'
- elif kind == 'Marseyflag': kind = 'Marsey Flags'
- elif kind == 'Marseyalphabet': kind = 'Marsey Alphabet'
-
- if kind in EMOJI_KINDS:
- emoji = g.db.query(Emoji.name).filter_by(kind=kind).order_by(func.random()).first()[0]
-
-
emoji_partial_pat = '
'
emoji_partial = '
'
emoji_html = None