-def sendXmppMsg(recipients, msg, resource = "torwaechter", addtimestamp = True, noofflinemsg = False):
- if type(recipients) == types.ListType:
- recipients = " ".join(recipients)
- if type(recipients) == types.UnicodeType:
- recipients = recipients.decode("utf-8")
- if type(recipients) != types.StringType:
- raise Exception("argument recipients not a space separated string or xmpp addresses, can't send message")
- if recipients == "" or msg == "":
- return
-
- sendxmpp_cmd = "sendxmpp -u realrauminfo -p 5SPjTdub -j jabber.tittelbach.at -t "
- if resource:
- sendxmpp_cmd += "-r %s " % resource
- if noofflinemsg:
- sendxmpp_cmd += "--headline "
- sendxmpp_cmd += recipients
-
- if addtimestamp:
- msg += time.strftime(" (%Y-%m-%d %T)")
-
- popenTimeout2(sendxmpp_cmd, msg)
-
-
-xmpp_msg_lastmsg = ""
-action_by = ""
-xmpp_firstmsg = True
-
-def distributeXmppMsg(msg,high_priority=False):
- global xmpp_firstmsg, xmpp_msg_lastmsg
- if xmpp_firstmsg:
- xmpp_msg_lastmsg = msg
- xmpp_firstmsg = False
- if msg != xmpp_msg_lastmsg:
- sendXmppMsg(uwscfg.xmpp_recipients_normal, msg)
- sendXmppMsg(uwscfg.xmpp_recipients_nooffline, msg, noofflinemsg=(not high_priority))
- else:
- sendXmppMsg(uwscfg.xmpp_recipients_debug, "D: " + msg)
- xmpp_msg_lastmsg = msg
-