-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
59 lines (52 loc) · 2.11 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
local SavedSendChatMessage = SendChatMessage;
local characterReplacement = {}
characterReplacement['a'] = {7, 'a', 'á', 'à', 'â', 'ä', 'å', 'ª'}
characterReplacement['A'] = {6, 'A', 'Á','À','Â','Ä','Å'}
characterReplacement['c'] = {2, 'c', 'ç'}
characterReplacement['C'] = {2, 'C', 'Ç'}
characterReplacement['e'] = {5, 'e', 'é', 'è', 'ê', 'ë'}
characterReplacement['E'] = {6, 'E', 'É', 'È', 'Ê', 'Ë', '€'}
characterReplacement['f'] = {2, 'f', 'ƒ'}
characterReplacement['i'] = {5, 'i', 'í', 'ì', 'î', 'ï'}
characterReplacement['I'] = {5, 'I', 'Í', 'Ì', 'Î', 'Ï'}
characterReplacement['n'] = {2, 'n', 'ñ'}
characterReplacement['N'] = {2, 'N', 'Ñ'}
characterReplacement['o'] = {6, 'o', 'ó', 'ò', 'ô', 'ö', 'º'}
characterReplacement['O'] = {5, 'O', 'Ó', 'Ò', 'Ô', 'Ö'}
characterReplacement['u'] = {6, 'u', 'ú', 'ù', 'û', 'ü', 'µ'}
characterReplacement['U'] = {5, 'U', 'Ú', 'Ù', 'Û', 'Ü'}
characterReplacement['y'] = {3, 'y', 'ý', 'ÿ'}
characterReplacement['Y'] = {2, 'Y', 'Ý'}
characterReplacement['b'] = {2, 'b', 'ß'}
characterReplacement['B'] = {2, 'B', 'ß'}
local impresive_enabled = true;
SLASH_IMPON1, SLASH_IMPOFF1 = '/impon', '/impoff';
function SlashCmdList.IMPON(msg, editbox)
impresive_enabled = true;
end
function SlashCmdList.IMPOFF(msg, editbox)
impresive_enabled = false;
end
function has_key(table, key)
return table[key]~=nil
end
function Impress_Message(msg)
local replacementString = ""
msg:gsub(".", function(c)
if has_key(characterReplacement, c) then
local numReplacementChars = characterReplacement[c][1]
local chosenIndex = math.random(1, numReplacementChars) + 1
replacementString = replacementString..characterReplacement[c][chosenIndex]
else
replacementString = replacementString..c
end
end)
return replacementString
end
function Impresive_SendChatMessage(msg, system, language, channel)
if impresive_enabled == true then
msg = Impress_Message(msg)
end
SavedSendChatMessage(msg, system, language, channel);
end
SendChatMessage = Impresive_SendChatMessage;