Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --// Emoji-Chat
- --// Written by Variable
- -- set up json array for emojis
- local dat = game:HttpGet('https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.json')
- local json = game:getService'HttpService':JSONDecode(dat)
- -- set variables for hooking
- local mt = getrawmetatable(game)
- local oldNameCall = mt.__namecall
- local oldFireServer = Instance.new('RemoteEvent').FireServer
- -- return the emoji unicode from a string
- function parseEmoji(emoji)
- for _,v in next, json do
- if (emoji:lower() == v['short_name']) then
- return utf8.char(tonumber(v['unified'], 16))
- end
- end
- end
- -- Lua doesn't have string.split
- function split(self, sep)
- local sep, fields = sep or ":", {}
- local pattern = string.format("([^%s]+)", sep)
- self:gsub(pattern, function(c) fields[#fields+1] = c end)
- return fields
- end
- -- detect if :emoji: exists
- function detectEmoji(str)
- for i=1, #str do
- if (str:sub(i,i) == ':') then
- local substr = str:sub(i+1, #str)
- local pos = substr:find(':')
- if (pos) then
- return pos
- end
- end
- end
- return nil
- end
- -- return a new string that formats a string with emojis =D
- function parseSemicolon(rawStr)
- local tbl = split(rawStr, " ")
- local newtbl = {}
- for i,token in next, tbl do
- local pos = detectEmoji(token)
- if (pos) then
- token = token:sub(2, pos)
- token = parseEmoji(token)
- end
- newtbl[i] = token
- end
- return table.concat(newtbl, ' ')
- end
- -- hook SayMessageRequest to parse emojis =D
- mt.__namecall = function(...)
- local tbl = {...}
- local key = tbl[#tbl]
- local obj = tbl[1]
- if (key == 'FireServer') then
- if (tostring(obj) == 'SayMessageRequest') then
- -- fireServer(self, message, channel)
- return oldFireServer(tbl[1], parseSemicolon(tbl[2]), tbl[3])
- end
- end
- return oldNameCall(...)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement