Added a DND-list for "!all" messages

master
Stefan Krulj 13 years ago
parent 7446e24ba5
commit 509ede3b0d
  1. 28
      modules/active/notify_all.py

@ -2,16 +2,38 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import brathuhn 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): def notify_all(msg, args):
message = ""; message = "";
arg1 = ""
if len(args)>=2:
arg1 = args[1]
userJID = brathuhn.getUsers().items() 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: for a in userJID:
message += "{0}, ".format(a[0].getResource()); res = a[0].getResource()
if not res in dnd:
message += "{0}, ".format(res)
message = message[:-2]; message = message[:-2];
@ -25,7 +47,7 @@ def notify_all(msg, args):
############################################## ##############################################
brathuhn.addCommand("all","Usage: !all [msg]; Notify everyone in Channel", notify_all) brathuhn.addCommand("all","Usage: !all [(dnd|message)]; Notify everyone in Channel, dnd-sets and unsets notification", notify_all)
############################################## ##############################################

Loading…
Cancel
Save