From 92645bbc578fafeb6816a44b8cf9cd594ffb5bd7 Mon Sep 17 00:00:00 2001 From: CiaranG Date: Fri, 22 Aug 2008 15:10:32 -0400 Subject: XMPP sub/unsub and help commands darcs-hash:20080822191032-f6e2c-a3a7efbbaad1ec7c48ef132a8ba34fc8b8651969.gz --- scripts/xmppdaemon.php | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'scripts') 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; } -- cgit v1.2.3-54-g00ecf