ZNC module to notify of pings over XMPP.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
764 B

import znc
import subprocess
class xmppnotify(znc.Module):
description = "XMPP notification module"
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