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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Jul 14 19:31:05 MSD 2007


Author: kostix
Date: 2007-07-14 19:31:04 +0400 (Sat, 14 Jul 2007)
New Revision: 16

Added:
   trunk/plugins/presencecmd/VERSION
Modified:
   trunk/plugins/presencecmd/README
   trunk/plugins/presencecmd/TODO
   trunk/plugins/presencecmd/presencecmd.tcl
Log:
presencecmd:
* presencecmd.tcl:
  * Regexp which parsed the command is substituted by the manual parsing.
    This fixed the bug with status message text being sometimes parsed as
	the presence if the presence field was omitted.
  * "Unknown presence" message made more elaborate -- now it shows acceptable
    values for the presence field.
* README: several typos fiexd, several parts of text made more clear.
* TODO: updated.
* VERSION: added "current version" file.

Released as version 0.2.


Modified: trunk/plugins/presencecmd/README
===================================================================
--- trunk/plugins/presencecmd/README	2007-07-14 00:48:55 UTC (rev 15)
+++ trunk/plugins/presencecmd/README	2007-07-14 15:31:04 UTC (rev 16)
@@ -3,11 +3,12 @@
 
 I. The idea.
 
-This plugin provides additional set of what is called "IRC-style
-chat command" in Tkabber -- specially formatted messages which
-are recognized as commands to Tkabber. They are parsed and
-executed and their text is thrown away (widely known examples of
-standard chat commands are: /clear, /nick, /ban, etc).
+This plugin provides additional set of what are called
+"IRC-style chat commands" in Tkabber -- specially formatted
+messages which are recognized as commands to Tkabber. They are
+parsed and executed, then  their text is thrown away (widely
+known examples of standard chat commands are: /clear, /nick,
+/ban, /leave, etc).
 
 Provided commands are:
 * /presence allows to change "master" (i.e. basic, main,
@@ -20,19 +21,21 @@
 
 II. Usage.
 
-Both commands have identical syntax and they behave identical --
-only the "presence instance" they operate on changes.
+Both commands have identical syntax and they behave identically
+-- changes only the presence they operate on.
 
 The formal syntax is:
 /presence ?presence|clear[status]?
 ?status message?
 
-(Fields surrounded by "?" represent optional parts.)
+Fields surrounded by "?" represent optional parts, so does text
+in [...]. "|" specifies alteration (a set of mutually exclusive
+options).
 
-Note that while both presence and status message are marked
-optional at least one of them MUST appear. Otherwise the command
-has no sense and the usage message is shown in the chat log
-window.
+Note that while both presence and status message fields are
+marked optional at least one of them MUST appear. Otherwise the
+command has no sense and the usage info is shown in the chat
+log window.
 
 The presence field may have this (standard) values, literally:
 * available -- user is available;
@@ -42,7 +45,7 @@
 * dnd -- user doesn't want to be disturbed;
 * chat -- user is free for chat.
 
-Note that there's currently no support for "unavail"
+Note that there's currently no support for "unavailable"
 presence.
 
 The special value of the presence field is "clearstatus"
@@ -52,13 +55,13 @@
 
 The status message field may be used to provide status message
 for the presence. Any text, on a new line after the command (and
-the presence value, if specified) is theated as the status
+the presence value, if specified) is treated as the status
 message, so it can span multiple lines and have empty lines in
 between. The only transformation that is applied to the status
 message is removal of any leading and trailing whitespace.
 
-Any of this fields (but not all) may be omitted. In this case
-its current value is kept intact.
+Any of this fields both) may be omitted. In this case
+the current value for the omitted field is kept intact.
 
 III. Examples:
 

Modified: trunk/plugins/presencecmd/TODO
===================================================================
--- trunk/plugins/presencecmd/TODO	2007-07-14 00:48:55 UTC (rev 15)
+++ trunk/plugins/presencecmd/TODO	2007-07-14 15:31:04 UTC (rev 16)
@@ -2,13 +2,6 @@
 
 HIGH:
 
-* Occasionally "status change only" commands are parsed incorrectly --
-  the status gets parsed as presence, say, in:
-  /chatstatus
-  suxx
-
-  (Actual cause unknown.)
-
 LOW:
 
 * Write provide ChangeLog and VERSION files.

Added: trunk/plugins/presencecmd/VERSION
===================================================================
--- trunk/plugins/presencecmd/VERSION	                        (rev 0)
+++ trunk/plugins/presencecmd/VERSION	2007-07-14 15:31:04 UTC (rev 16)
@@ -0,0 +1 @@
+0.2, 14-July-2007

Modified: trunk/plugins/presencecmd/presencecmd.tcl
===================================================================
--- trunk/plugins/presencecmd/presencecmd.tcl	2007-07-14 00:48:55 UTC (rev 15)
+++ trunk/plugins/presencecmd/presencecmd.tcl	2007-07-14 15:31:04 UTC (rev 16)
@@ -25,17 +25,17 @@
 proc presencecmd::handle_command {chatid user body type} {
 	global userstatus
 
-	if {!([string match {/presence*} $body] \
-	|| [string match {/chatpresence*} $body] \
-	|| [string match {/thispresence*} $body])} return
+	if {[string match {/presence*} $body]} {
+		set cmd /presence
+	} elseif {[string match {/chatpresence*} $body]} {
+		set cmd /chatpresence
+	} elseif {[string match {/thispresence*} $body]} {
+		set cmd /thispresence
+	} else return
 
-	if {![regexp {^(/presence|/chatpresence|/thispresence)(?:\s*)(\w*)(?:\s*\n(.*))?$} \
-		$body - cmd pres status]} {
-		show_usage $chatid
-		return stop
-	}
-
-	set status [string trim $status]
+	set fields [split $body \n]
+	set pres   [string trim [string range [lindex $fields 0] [string length $cmd] end]]
+	set status [string trim [join [lrange $fields 1 end] \n]]
 	set sendstatus [expr {$status != ""}]
 
 	if {$pres == "" && !$sendstatus} {
@@ -61,7 +61,8 @@
 				set status ""
 			}
 			default {
-				show error $chatid [::msgcat::mc "Unknown presence: %s" $pres]
+				show error $chatid [::msgcat::mc "Unknown presence \"%s\".\
+					Must be avail\[able\], away, xa, dnd, chat or clear\[status\]" $pres]
 				return stop
 			}
 		}
@@ -106,14 +107,14 @@
 
 proc presencecmd::show_usage chatid {
 	show error $chatid [::msgcat::mc "Usage:\
-\t/presence ?presence|clear\[status\]?\n\
-\t?status message?\n\
-or\n\
-\t/chatpresence ?presence|clear\[status\]?\n\
-\t?status message?\n\
-Where presence is one of: avail\[able\], away, xa, dnd, chat.\n\
-Special presence \"clear\[status\]\" just clears the current status.\n\
-/thispresence is an alias for /chatpresence"]
+		\t/presence ?presence|clear\[status\]?\n\
+		\t?status message?\n\
+		or\n\
+		\t/chatpresence ?presence|clear\[status\]?\n\
+		\t?status message?\n\
+		Where presence is one of: avail\[able\], away, xa, dnd, chat.\n\
+		Special presence \"clear\[status\]\" just clears the current status.\n\
+		/thispresence is an alias for /chatpresence"]
 }
 
 # $type should be either "info" or "error"



More information about the Tkabber-dev mailing list