2020-05-27 02:23:02 +10:00
|
|
|
import znc
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
class xmppnotify(znc.Module):
|
2020-05-27 02:52:01 +10:00
|
|
|
description = "XMPP notification module"
|
2020-05-27 02:23:02 +10:00
|
|
|
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
|