[Tkabber-dev] r14 - trunk/plugins/presencecmd

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Jul 13 22:29:54 MSD 2007


Author: kostix
Date: 2007-07-13 22:29:53 +0400 (Fri, 13 Jul 2007)
New Revision: 14

Added:
   trunk/plugins/presencecmd/AUTHORS
   trunk/plugins/presencecmd/INSTALL
   trunk/plugins/presencecmd/TODO
   trunk/plugins/presencecmd/license.terms
   trunk/plugins/presencecmd/presencecmd.tcl
Log:
Initial import of "presencecmd" plugin files.


Added: trunk/plugins/presencecmd/AUTHORS
===================================================================
--- trunk/plugins/presencecmd/AUTHORS	                        (rev 0)
+++ trunk/plugins/presencecmd/AUTHORS	2007-07-13 18:29:53 UTC (rev 14)
@@ -0,0 +1 @@
+Konstantin Khomoutov <flatworm at users.sourceforge.com>

Added: trunk/plugins/presencecmd/INSTALL
===================================================================
--- trunk/plugins/presencecmd/INSTALL	                        (rev 0)
+++ trunk/plugins/presencecmd/INSTALL	2007-07-13 18:29:53 UTC (rev 14)
@@ -0,0 +1,9 @@
+As usually, copy this directory under the ~/.tkabber/plugins directory
+so that you get a hierarchy like this:
+  ~/.tkabber/plugins
+  ~/.tkabber/plugins/presencecmd/
+  ~/.tkabber/plugins/presencecmdv/presencecmd.tcl
+
+Restart Tkabber, to get the plugin loaded.
+Consult the README file for the details about using this plugin.
+

Added: trunk/plugins/presencecmd/TODO
===================================================================
--- trunk/plugins/presencecmd/TODO	                        (rev 0)
+++ trunk/plugins/presencecmd/TODO	2007-07-13 18:29:53 UTC (rev 14)
@@ -0,0 +1,16 @@
+$Id$
+
+HIGH:
+
+* Fix regexp so that it:
+  * Allows for empty presence;
+  * Allows for non-empty status.
+
+* Provide for actual change of presence and/or status if parsed successfully.
+
+LOW:
+
+* Write README, provide ChangeLog and VERSION files.
+
+* Russian message catalog.
+


Property changes on: trunk/plugins/presencecmd/TODO
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/plugins/presencecmd/license.terms
===================================================================
--- trunk/plugins/presencecmd/license.terms	                        (rev 0)
+++ trunk/plugins/presencecmd/license.terms	2007-07-13 18:29:53 UTC (rev 14)
@@ -0,0 +1,19 @@
+Copyright (c) 2007 Konstantin Khomoutov <flatworm at users.sourceforge.net>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.

Added: trunk/plugins/presencecmd/presencecmd.tcl
===================================================================
--- trunk/plugins/presencecmd/presencecmd.tcl	                        (rev 0)
+++ trunk/plugins/presencecmd/presencecmd.tcl	2007-07-13 18:29:53 UTC (rev 14)
@@ -0,0 +1,79 @@
+# $Id$
+# "Presence commands" -- Tkabber chat plugin.
+# Provides two IRC-style chat commands that provide
+# for manipulating user's presence and/or assotiated status message
+# as well as sending directed presence to the chat peer (or room).
+# Written by Konstantin Khomoutov <flatworm at users.sourceforge.net>
+# See license.terms for details on distribution.
+# See INSTALL and README for details on installation and usage.
+
+namespace eval presencecmd {
+	hook::add generate_completions_hook \
+		[namespace current]::command_comps
+	hook::add chat_send_message_hook \
+		[namespace current]::handle_command 15
+}
+
+proc presencecmd::command_comps {chatid compsvar wordstart line} {
+	upvar 0 $compsvar comps
+    
+	if {!$wordstart} {
+		lappend comps {/presence } {/chatpresence }
+	}
+}
+
+if 0 {
+	Use cases:
+	/presence avail
+	/presence xa
+	gone shopping!
+	/presence
+	woohoo!
+}
+
+# RE1: {^(/presence|/chatpresence)(?!\S+)([^\n]+)(?!\n?(.+))$}
+
+proc presencecmd::handle_command {chatid user body type} {
+	if {!([string match {/presence*} $body] \
+	|| [string match {/chatpresence*} $body])} return
+
+	# TODO fix regexp: must allow empty presence and non-empty status
+	if {![regexp {^(/presence|/chatpresence)(?!\S+)([^\n]+)(?!\n?(.+))$} \
+		$body - cmd pres status]} {
+		show info $chatid [::msgcat::mc "Usage:\
+			\t/presence PRESENCE\n\
+			\t?status message?\n\
+			or\n\
+			\t/chatpresence PRESENCE\n\
+			\t?status message?\n\
+			Where PRESENCE is one of: avail\[able\], away, xa, dnd"]
+		return stop
+	}
+
+	set pres [string trim $pres]
+
+	switch -- $pres {
+		avail -
+		available -
+		away -
+		xa -
+		dnd {}
+		default {
+			show error $chatid [::msgcat::mc "Unknown presence: %s" $pres]
+			return stop
+		}
+	}
+
+	show info $chatid "pres: <$pres>\nstatus: <$status>"
+	# TODO change presence here
+
+	return stop
+}
+
+# $type should be either "info" or "error"
+proc presencecmd::show {type chatid msg} {
+	set jid [chat::get_jid $chatid]
+	set cw [chat::chat_win $chatid]
+
+	chat::add_message $chatid $jid $type $msg {}
+}


Property changes on: trunk/plugins/presencecmd/presencecmd.tcl
___________________________________________________________________
Name: svn:keywords
   + Id



More information about the Tkabber-dev mailing list