Jabber/XMPP conference bot & framework
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.
brathuhn/modules/active/notify_all.py

53 lines
1.3 KiB

#!/usr/bin/python
# -*- coding: utf-8 -*-
import brathuhn
from persistent import PersistentContainer
import config
##############################################
container = PersistentContainer(__name__+'_data',config.PCACHE)
if not "dnd" in container:
container["dnd"] = {}
def notify_all(msg, args):
message = "";
arg1 = ""
if len(args)>=2:
arg1 = args[1]
userJID = brathuhn.getUsers().items()
dnd = container["dnd"]
res = msg.getFrom().getResource() #TODO ugly
if arg1 == "dnd":
if not res in dnd:
dnd[res] = True
brathuhn.sendMsg(brathuhn.ROOM, "You won't be disturbed by \"!all\" anymore",'groupchat')
else:
del dnd[res]
brathuhn.sendMsg(brathuhn.ROOM, "You will be notified by \"!all\" messages",'groupchat')
container["dnd"] = dnd
return
for a in userJID:
res = a[0].getResource()
if not res in dnd:
message += "{0}, ".format(res)
message = message[:-2];
if len(args)>=2 and args[1] != "":
message += ": ";
for a in args[1:]:
message += "{0} ".format(a);
brathuhn.sendMsg(brathuhn.ROOM, message,'groupchat')
##############################################
brathuhn.addCommand("all","Usage: !all [(dnd|message)]; Notify everyone in Channel, dnd-sets and unsets notification", notify_all)
##############################################