Module:Emoji
Appearance
Module:Emoji implements two functions:
- emocode
- Takes one unnamed parameter, the name of the emoji, and returns the hex code for the corresponding emoji. If no name is supplied it uses "smiley" as the default (and returns
1f603
). - emoname
- Takes one unnamed parameter, the hex code of the emoji, and returns the name for the corresponding emoji. If no name is supplied it uses "1f603" as the default (and returns
smiley
).
It stores the mapping from name to code in Module:Emoji/data, which internally generates the reverse lookup table from code to name.
Examples
{{#invoke:Emoji | emocode | wink}}
→wink
{{#invoke:Emoji | emocode | grin}}
→grin
{{#invoke:Emoji | emocode | 8ball}}
→8ball
{{#invoke:Emoji | emocode }}
→smiley
{{#invoke:Emoji | emoname | 1f62b}}
→1f62b
{{#invoke:Emoji | emoname }}
→1f603
local p= {}
local emotbl = mw.loadData ('Module:Emoji/data');
function p.emocode(frame)
local emoname = mw.text.trim(frame.args[1] or "smiley")
return emotbl[emoname] or emoname
end
function p.emoname(frame)
local emocode = mw.text.trim(frame.args[1] or "1f603")
local match
for k, v in pairs(emotbl) do
if v == emocode then
match = k
break
end
end
return match or emocode
end
return p