|
|
|
|
@ -2,30 +2,52 @@ |
|
|
|
|
# -*- 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 = ""; |
|
|
|
|
userJID = brathuhn.getUsers().items() |
|
|
|
|
for a in userJID: |
|
|
|
|
message += "{0}, ".format(a[0].getResource()); |
|
|
|
|
|
|
|
|
|
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') |
|
|
|
|
|
|
|
|
|
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 [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) |
|
|
|
|
|
|
|
|
|
############################################## |
|
|
|
|
|
|
|
|
|
|