From 7b7a5586bced9cae69996571f978a2e477866c4d Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Wed, 27 May 2020 02:23:02 +1000 Subject: [PATCH] import module from production --- xmppnotify.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 xmppnotify.py 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