Last active
May 4, 2018 23:40
-
-
Save valesi/6847413fa86cc90500f4287962598436 to your computer and use it in GitHub Desktop.
ZNC 1.7.0 buffextras for HexChat in lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hexchat.register('ZNC Buffextras', '1.2.1', "Format messages from ZNC's buffextras module") | |
-- TODO: parse out raw modes to proper hexchat event (maybe...) | |
hexchat.hook_server_attrs('PRIVMSG', function (word, word_eol, attrs) | |
if not word[1]:match('^:%*buffextras!') then | |
return | |
end | |
local channel = word[3] | |
local nick = word[4]:match('^:([^!]+)') | |
local host = word[4]:match('!(.*)$') | |
local function is_event (event) | |
return word_eol[5]:sub(1, #event) == event | |
end | |
local function emit (event, ...) | |
hexchat.emit_print_attrs(attrs, event, ...) | |
end | |
if is_event('joined') then | |
emit('Join', nick, channel, host) | |
elseif is_event('quit:') then | |
emit('Quit', nick, word_eol[6], host) | |
elseif is_event('parted:') then | |
local reason = word_eol[6] | |
if reason then | |
emit('Part with Reason', nick, host, channel, reason) | |
else | |
emit('Part', nick, host, channel) | |
end | |
elseif is_event('is now known as') then | |
emit('Change Nick', nick, word[9]) | |
elseif is_event('changed the topic to') then | |
emit('Topic Change', nick, word_eol[9], channel) | |
elseif is_event('kicked') then | |
emit('Kick', nick, word[6], channel, word_eol[9]) | |
elseif is_event('set mode') then | |
emit('Raw Modes', nick, string.format('%s %s', channel, word_eol[7])) | |
else | |
return -- Unknown event | |
end | |
return hexchat.EAT_ALL | |
end, hexchat.PRI_HIGH) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment