From 632f6f07e92ffbcddec14a13b0a7cde256631d95 Mon Sep 17 00:00:00 2001 From: fbr Date: Sat, 8 Dec 2012 21:44:32 +0100 Subject: [PATCH] added module notify_all, small change in module-loader in main.py --- main.py | 3 +++ modules/active/notify_all.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 modules/active/notify_all.py diff --git a/main.py b/main.py index 52b0efb..9c1fe18 100755 --- a/main.py +++ b/main.py @@ -9,6 +9,7 @@ cwd = os.getcwd() sys.path.append(os.path.join(cwd,"sys")) sys.path.append(os.path.join(cwd,"modules","active")) +print cwd import demonize, brathuhn, config #Demonize if not demonize.demonize(config.PIDFILE,False,config.LOGFILE): @@ -23,6 +24,8 @@ for f in files: mod = f[:-3] elif f.endswith(".pyc"): mod = f[:-4] + else: + continue; if not mod in modules: modules.append(mod) for mod in modules: diff --git a/modules/active/notify_all.py b/modules/active/notify_all.py new file mode 100644 index 0000000..865f583 --- /dev/null +++ b/modules/active/notify_all.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import brathuhn + + +############################################## + + +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') + + +############################################## + +brathuhn.addCommand("all","Usage: !all [msg]; Notify everyone in Channel", notify_all) + +############################################## +