[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: How can I do PCRE-y stuff in Lua Patterns?
- From: "Soni L." <fakedme@...>
- Date: Sat, 30 Sep 2017 20:41:51 -0300
I have this hexchat module:
------
local hexchat = hexchat
hexchat.register("Fancy Input", "1.1.0", "Just input hacks.")
local PATTERN = '%f[^ \0]<<([^ ].-)>>%f[ \0] ?'
hexchat.hook_command(nil, function(word, word_eol)
local msg = word_eol[1]
if not msg:find(PATTERN) then return end
local channel = hexchat.get_info("channel")
hexchat.command("quote PRIVMSG " .. channel .. " :" ..
msg:gsub(PATTERN, '\1ACTION %1\1'))
local NICK, MODE, TEXT = hexchat.get_info("nick"), nil, ""
for user in hexchat.iterate("users") do
if hexchat.nickcmp(user.nick, NICK) == 0 then
MODE = user.prefix
end
end
hexchat.emit_print("Your Message", NICK, msg:gsub(PATTERN,
'\x1D%1\x1D '), MODE, TEXT)
return hexchat.EAT_ALL
end, nil, hexchat.PRI_LOWEST)
hexchat.print("Fancy Input loaded")
------
And it works pretty good, except for e.g. "test <<thing>>" which gets
sent as "test \1ACTION thing\1" and I'd rather it be sent as
"test\1ACTION thing\1".
I realize this may not be possible, in which case, well, it's only one
byte so not a big deal, but I still thought I'd ask because I never
really used frontier pattern before and I think it's awesome that I can
even do what I'm currently doing. :P
--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.