Created
May 26, 2013 20:53
-
-
Save nathanharper/5653993 to your computer and use it in GitHub Desktop.
Simple notification script for weechat, uses my fork of lnotify
This file contains hidden or 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
weechat.register("weenote", | |
"Nathan", | |
"1.0", | |
"Beerware", | |
"My personal notification script", | |
"", | |
"UTF-8") | |
local settings = { | |
match = "my_nick" | |
} | |
local note = require "notify" | |
local wcpic = os.getenv('HOME') .. '/.weechat/assets/weechat.png' | |
do -- initialize plugin settings | |
local match = weechat.config_get_plugin('match') | |
if match ~= "" then | |
settings.match = match | |
else | |
weechat.config_set_plugin('match', settings.match) | |
end | |
end | |
function regex_format(str) | |
return table.concat{"%f[%w_]", str, "%f[^%w_]"} | |
end | |
function notify_me(_,_,_,_,_,_,_,msg) | |
-- local tab = {...} | |
-- local msg = tab[8] | |
if settings.match and msg:match(regex_format(settings.match)) then | |
-- for k,v in pairs(tab) do weechat.print("", k.." : "..v) end | |
local ni = note.new("Weechat Message", msg, wcpic) | |
note.set_urgency(ni, 'critical') | |
note.show(ni) | |
end | |
end | |
function config_cb(data, option, value) | |
settings.match = value | |
end | |
weechat.hook_print("", "irc_privmsg,irc_msg", "", 1, "notify_me", 0) | |
weechat.hook_config("plugins.var.lua.weenote.match", "config_cb", "") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment