summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorCiaranG <ciaran@ciarang.com>2008-08-22 15:10:32 -0400
committerCiaranG <ciaran@ciarang.com>2008-08-22 15:10:32 -0400
commit92645bbc578fafeb6816a44b8cf9cd594ffb5bd7 (patch)
treeb539bb071b2a037e77d219f0bb0a8eaae1bdc22b /scripts
parentce3cdb20c05b5ad7321d109dc5e0f3b83d828f88 (diff)
XMPP sub/unsub and help commands
darcs-hash:20080822191032-f6e2c-a3a7efbbaad1ec7c48ef132a8ba34fc8b8651969.gz
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/xmppdaemon.php36
1 files changed, 35 insertions, 1 deletions
diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php
index 864782098..1db6687d0 100755
--- a/scripts/xmppdaemon.php
+++ b/scripts/xmppdaemon.php
@@ -208,15 +208,49 @@ class XMPPDaemon {
function handle_command($user, $body) {
# XXX: localise
- switch(trim($body)) {
+ $p=explode(' ',$body);
+ if(count($p)>2)
+ return false;
+ switch($p[0]) {
+ case 'help':
+ if(count($p)!=1)
+ return false;
+ $this->from_site($user->jabber, "Commands:\n on - turn on notifications\n off - turn off notifications\n help - show this help \n sub - subscribe to user\n unsub - unsubscribe from user");
+ return true;
case 'on':
+ if(count($p)!=1)
+ return false;
$this->set_notify($user, true);
$this->from_site($user->jabber, 'notifications on');
return true;
case 'off':
+ if(count($p)!=1)
+ return false;
$this->set_notify($user, false);
$this->from_site($user->jabber, 'notifications off');
return true;
+ case 'sub':
+ if(count($p)==1) {
+ $this->from_site($user->jabber, 'Specify the name of the user to subscribe to');
+ return true;
+ }
+ $result=subs_subscribe_user($user, $p[1]);
+ if($result=='true')
+ $this->from_site($user->jabber, 'Subscribed to ' . $p[1]);
+ else
+ $this->from_site($user->jabber, $result);
+ return true;
+ case 'unsub':
+ if(count($p)==1) {
+ $this->from_site($user->jabber, 'Specify the name of the user to unsubscribe from');
+ return true;
+ }
+ $result=subs_unsubscribe_user($user, $p[1]);
+ if($result=='true')
+ $this->from_site($user->jabber, 'Unsubscribed from ' . $p[1]);
+ else
+ $this->from_site($user->jabber, $result);
+ return true;
default:
return false;
}