slack.lua: add a feature to undo emoji
This commit is contained in:
parent
757047bd20
commit
f7dce5e861
|
@ -24,12 +24,52 @@ local read_servers = function (v)
|
|||
end
|
||||
end
|
||||
|
||||
-- This is a reverse list of Slack's automatic emoji, noseless forms
|
||||
local unemojify, emoji, emoji_default = false, {}, {
|
||||
heart = "<3",
|
||||
broken_heart = "</3",
|
||||
sunglasses = "8)",
|
||||
anguished = "D:",
|
||||
cry = ":'(",
|
||||
monkey_face = ":o)",
|
||||
kiss = ":*",
|
||||
smiley = "=)",
|
||||
smile = ":D",
|
||||
wink = ";)",
|
||||
laughing = ":>",
|
||||
neutral_face = ":|",
|
||||
open_mouth = ":o",
|
||||
angry = ">:(",
|
||||
slightly_smiling_face = ":)",
|
||||
disappointed = ":(",
|
||||
confused = ":/",
|
||||
stuck_out_tongue = ":p",
|
||||
stuck_out_tongue_winking_eye = ";p",
|
||||
}
|
||||
local load_emoji = function (extra)
|
||||
emoji = {}
|
||||
for k, v in pairs (emoji_default) do emoji[k] = v end
|
||||
for k, v in extra:gmatch "([^,]+) ([^,]+)" do emoji[k] = v end
|
||||
end
|
||||
|
||||
degesch.setup_config {
|
||||
servers = {
|
||||
type = "string_array",
|
||||
default = "\"\"",
|
||||
comment = "list of server names that are Slack IRC gateways",
|
||||
on_change = read_servers
|
||||
},
|
||||
unemojify = {
|
||||
type = "boolean",
|
||||
default = "true",
|
||||
comment = "convert emoji to normal ASCII emoticons",
|
||||
on_change = function (v) unemojify = v end
|
||||
},
|
||||
extra_emoji = {
|
||||
type = "string_array",
|
||||
default = "\"grinning :)),joy :'),innocent o:),persevere >_<\"",
|
||||
comment = "overrides or extra emoji for unemojify",
|
||||
on_change = function (v) load_emoji (v) end
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,9 +88,16 @@ degesch.hook_irc (function (hook, server, line)
|
|||
.. msg.prefix:match "^[^!@]*" .. " :" .. text
|
||||
end)
|
||||
|
||||
-- Unfuck :nick!nick@irc.tinyspeck.com MODE #channel +v nick : active
|
||||
-- Unfuck emoji and :nick!nick@irc.tinyspeck.com MODE #channel +v nick : active
|
||||
degesch.hook_irc (function (hook, server, line)
|
||||
if not servers[server.name] then return line end
|
||||
if unemojify then
|
||||
local start, text = line:match ("^(.- PRIVMSG .-:)(.*)$")
|
||||
if start then return start .. text:gsub (":([a-z_]+):", function (name)
|
||||
if emoji[name] then return emoji[name] end
|
||||
return ":" .. name .. ":"
|
||||
end) end
|
||||
end
|
||||
return line:gsub ("^(:%S+ MODE .+) : .*", "%1")
|
||||
end)
|
||||
|
||||
|
|
Loading…
Reference in New Issue