diff --git a/xmppnotify.py b/xmppnotify.py new file mode 100644 index 0000000..8112f70 --- /dev/null +++ b/xmppnotify.py @@ -0,0 +1,19 @@ +import znc +import subprocess + +class xmppnotify(znc.Module): + description = "XMPP notification module; just a test so far." + has_args = True + args_help_text = "XMPP address." + module_types = [znc.CModInfo.UserModule] + raddr = "" + def OnLoad(self,args,message): + self.raddr = args + message.s = "Loaded XMPP notification service to send notifications to " + self.raddr + return znc.CONTINUE + def OnChanMsg(self, nick, channel, message): + if str(message).__contains__(self.GetNetwork().GetNick()): + command = ["sendxmpp", "-t", self.raddr] + p = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + output = p.communicate(input="[{0}] <{1}> {2}".format(channel.GetName(), nick.GetNick(), message.s).encode())[0] + return znc.CONTINUE