import module from production

This commit is contained in:
Izaya 2020-05-27 02:23:02 +10:00
parent bcdfe3056e
commit 7b7a5586bc
1 changed files with 19 additions and 0 deletions

19
xmppnotify.py Normal file
View File

@ -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