diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2017-07-03 06:45:46 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2017-07-03 06:45:46 +0200 |
commit | f7dce5e861e90581dd1317847aa4ca6771323150 (patch) | |
tree | 257c105e27e0d4029d45c8eaa04bbc893ed5e511 /plugins | |
parent | 757047bd2004a6269ee54b5dd54d64db2369957f (diff) | |
download | xK-f7dce5e861e90581dd1317847aa4ca6771323150.tar.gz xK-f7dce5e861e90581dd1317847aa4ca6771323150.tar.xz xK-f7dce5e861e90581dd1317847aa4ca6771323150.zip |
slack.lua: add a feature to undo emoji
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/degesch/slack.lua | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/plugins/degesch/slack.lua b/plugins/degesch/slack.lua index 87786da..fb99b99 100644 --- a/plugins/degesch/slack.lua +++ b/plugins/degesch/slack.lua @@ -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) |