Merge pull request #2663 from buffyuwu/grammar1

Autocorrect
This commit is contained in:
Captain277
2021-02-06 21:46:18 -08:00
committed by GitHub
3 changed files with 43 additions and 0 deletions

View File

@@ -264,6 +264,39 @@
/proc/capitalize(var/t as text)
return uppertext(copytext(t, 1, 2)) + copytext(t, 2)
/proc/autocorrect(var/input as text) // syntax is "stringtoreplace"="stringtoreplacewith"
return input = replace_characters(input, list(
" i "=" I ",
"i'm"="I'm",
"s's"="s'",
"isnt"="isn't",
"dont"="don't",
"shouldnt"="shouldn't",
" ive "=" I've ",
"whos"="who's",
"whove"="who've",
"whod"="whod",
"whats"="whats",
"whatd"="whatd",
"thats"="thats",
"thatll"="thatll",
"thatd"="thatd",
" nows "=" nows ",
"isnt"="isnt",
" arent "=" arent ",
"wasnt"="wasnt",
"werent"="werent",
"havent"="havent",
"hasnt"="hasnt",
"hadnt"="hadnt",
"doesnt"="doesnt",
"didnt"="didnt",
"couldnt"="couldnt",
"wouldnt"="wouldnt",
"mustnt"="mustnt",
"shouldnt"="shouldnt"
))
//This proc strips html properly, remove < > and all text between
//for complete text sanitizing should be used sanitize()
/proc/strip_html_properly(var/input)

View File

@@ -342,3 +342,9 @@ var/list/_client_preferences_by_type
enabled_by_default = FALSE
enabled_description = "Obfuscate Ghost"
disabled_description = "Normal Ghost"
/datum/client_preference/autocorrect
description = "Autocorrect"
key = "AUTOCORRECT"
enabled_description = "Enabled"
disabled_description = "Disabled"

View File

@@ -215,6 +215,10 @@ proc/get_radio_key_from_channel(var/channel)
//Autohiss handles auto-rolling tajaran R's and unathi S's/Z's
message = handle_autohiss(message, speaking)
//autocorrect common typos
if(client?.is_preference_enabled(/datum/client_preference/autocorrect))
message = autocorrect(message)
//Whisper vars
var/w_scramble_range = 5 //The range at which you get ***as*th**wi****
var/w_adverb //An adverb prepended to the verb in whispers