mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-30 03:22:41 +00:00
* Refactors admin PMs to be hopefully more resilient * autoconflict resolution Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: Gandalf <9026500+Gandalf2k15@users.noreply.github.com>
56 lines
1.5 KiB
Plaintext
56 lines
1.5 KiB
Plaintext
/proc/emoji_parse(text) //turns :ai: into an emoji in text.
|
|
if(!text)
|
|
return text
|
|
. = text
|
|
if(!CONFIG_GET(flag/emojis))
|
|
return
|
|
var/static/list/emojis = icon_states(icon(EMOJI_SET))
|
|
var/parsed = ""
|
|
var/pos = 1
|
|
var/search = 0
|
|
var/emoji = ""
|
|
while(1)
|
|
search = findtext(text, ":", pos)
|
|
parsed += copytext(text, pos, search)
|
|
if(search)
|
|
pos = search
|
|
search = findtext(text, ":", pos + length(text[pos]))
|
|
if(search)
|
|
emoji = lowertext(copytext(text, pos + length(text[pos]), search))
|
|
var/datum/asset/spritesheet/sheet = get_asset_datum(/datum/asset/spritesheet/chat)
|
|
var/tag = sheet.icon_tag("emoji-[emoji]")
|
|
if(tag)
|
|
parsed += tag
|
|
pos = search + length(text[pos])
|
|
else
|
|
parsed += copytext(text, pos, search)
|
|
pos = search
|
|
emoji = ""
|
|
continue
|
|
else
|
|
parsed += copytext(text, pos, search)
|
|
break
|
|
return parsed
|
|
|
|
/proc/emoji_sanitize(text) //cuts any text that would not be parsed as an emoji
|
|
. = text
|
|
if(!CONFIG_GET(flag/emojis))
|
|
return
|
|
var/static/list/emojis = icon_states(icon(EMOJI_SET))
|
|
var/final = "" //only tags are added to this
|
|
var/pos = 1
|
|
var/search = 0
|
|
while(1)
|
|
search = findtext(text, ":", pos)
|
|
if(search)
|
|
pos = search
|
|
search = findtext(text, ":", pos + length(text[pos]))
|
|
if(search)
|
|
var/word = lowertext(copytext(text, pos + length(text[pos]), search))
|
|
if(word in emojis)
|
|
final += lowertext(copytext(text, pos, search + length(text[search])))
|
|
pos = search + length(text[search])
|
|
continue
|
|
break
|
|
return final
|