From bdc6334aec32a31ed41fc44bff09a0462cd48046 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Wed, 17 May 2017 00:32:54 +0200
Subject: slack.lua: more unfucking
And now it's already fairly usable.
---
plugins/degesch/slack.lua | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
(limited to 'plugins/degesch')
diff --git a/plugins/degesch/slack.lua b/plugins/degesch/slack.lua
index 79f5d88..89f0adf 100644
--- a/plugins/degesch/slack.lua
+++ b/plugins/degesch/slack.lua
@@ -48,6 +48,31 @@ degesch.hook_irc (function (hook, server, line)
.. msg.prefix:match "^[^!@]*" .. " :" .. text
end)
+-- Unfuck :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
+ return line:gsub ("^(:%S+ MODE .+) : .*", "%1")
+end)
+
+-- The gateway simply ignores the NAMES command altogether
+degesch.hook_input (function (hook, buffer, input)
+ if not buffer.channel or not servers[buffer.server.name]
+ or not input:match "^/names%s*" then return input end
+
+ local users = buffer.channel.users
+ table.sort (users, function (a, b)
+ if a.prefixes > b.prefixes then return true end
+ if a.prefixes < b.prefixes then return false end
+ return a.user.nickname < b.user.nickname
+ end)
+
+ local names = "Users on " .. buffer.channel.name .. ":"
+ for i, chan_user in ipairs (users) do
+ names = names .. " " .. chan_user.prefixes .. chan_user.user.nickname
+ end
+ buffer:log (names)
+end)
+
degesch.hook_completion (function (hook, data, word)
local chan = degesch.current_buffer.channel
local server = degesch.current_buffer.server
--
cgit v1.2.3-70-g09d2