Added a DND-list for "!all" messages

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

@ -2,30 +2,52 @@
# -*- 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 = "";
userJID = brathuhn.getUsers().items() arg1 = ""
for a in userJID: if len(args)>=2:
message += "{0}, ".format(a[0].getResource()); arg1 = args[1]
userJID = brathuhn.getUsers().items()
message = message[:-2]; dnd = container["dnd"]
if len(args)>=2 and args[1] != "": res = msg.getFrom().getResource() #TODO ugly
message += ": "; if arg1 == "dnd":
for a in args[1:]: if not res in dnd:
message += "{0} ".format(a); dnd[res] = True
brathuhn.sendMsg(brathuhn.ROOM, "You won't be disturbed by \"!all\" anymore",'groupchat')
brathuhn.sendMsg(brathuhn.ROOM, message,'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 [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