[Tkabber-dev] r204 - trunk/plugins/bldjid

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Apr 7 07:09:41 MSD 2009


Author: bigote
Date: 2009-04-07 07:09:41 +0400 (Tue, 07 Apr 2009)
New Revision: 204

Modified:
   trunk/plugins/bldjid/ChangeLog
   trunk/plugins/bldjid/README
   trunk/plugins/bldjid/TODO
   trunk/plugins/bldjid/bldjid.tcl
Log:
Added JIDs autocompletion for /bldjid, /banjid, /unbldjid, /unban commands
when using them after generating a user list by any of /visit* commands.
Thanks to Alexey Smirnov <mailto:alexey.smirnov at gmx.com>

Some typos and little mistakes corrected.


Modified: trunk/plugins/bldjid/ChangeLog
===================================================================
--- trunk/plugins/bldjid/ChangeLog	2009-04-06 23:35:01 UTC (rev 203)
+++ trunk/plugins/bldjid/ChangeLog	2009-04-07 03:09:41 UTC (rev 204)
@@ -1,5 +1,18 @@
 2009-04-07  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
 
+--- Version 0.5.9 of the plugin.
+--- Files modified:
+    bldjid.tcl, README, TODO, ChangeLog.
+
+--- Changes:
+	Added JIDs autocompletion for /bldjid, /banjid, /unbldjid, /unban commands
+	when using them after generating a user list by any of /visit* commands.
+	Thanks to Alexey Smirnov <mailto:alexey.smirnov at gmx.com>
+
+	Some typos and little mistakes corrected.
+
+2009-04-07  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
+
 --- Version 0.5.8 of the plugin.
 --- Files modified:
     bldjid.tcl, README, ChangeLog.

Modified: trunk/plugins/bldjid/README
===================================================================
--- trunk/plugins/bldjid/README	2009-04-06 23:35:01 UTC (rev 203)
+++ trunk/plugins/bldjid/README	2009-04-07 03:09:41 UTC (rev 204)
@@ -63,12 +63,13 @@
 
 where ?n? is an integer between 0 and the last item number.
 
---- At the moment /visit* commands do not follow match rules.
-	Instead, they make an exact search for a full room's JID
-	or a given nick. It will be fixed someday :)
-
 --- Autocompletion works for all these commands: write a couple
 	of the first letters of a command and hit TAB one of more times.
+-	Autocompletion also works in the same way for matching JIDs and nicks
+	when you use commands /bldjid, /banjid, /unban, /unbldjid
+	after generating a user list by any of /visit* commands.
+	If there is no such list, only nicks autocompletion works
+	(which is not what you need).
 
 =====================
 ####  CUSTOMIZE  ####

Modified: trunk/plugins/bldjid/TODO
===================================================================
--- trunk/plugins/bldjid/TODO	2009-04-06 23:35:01 UTC (rev 203)
+++ trunk/plugins/bldjid/TODO	2009-04-07 03:09:41 UTC (rev 204)
@@ -1,6 +1,3 @@
-=== Add autocompletion for JIDs when using /bldjid-like commands
-	after user list publishing. (Now Tkabber tries to insert present nicks).
-
 === Add an option to choose whether to list users directly in a chat window
 	or to open a special monitor window to show output.
 

Modified: trunk/plugins/bldjid/bldjid.tcl
===================================================================
--- trunk/plugins/bldjid/bldjid.tcl	2009-04-06 23:35:01 UTC (rev 203)
+++ trunk/plugins/bldjid/bldjid.tcl	2009-04-07 03:09:41 UTC (rev 204)
@@ -1,16 +1,18 @@
-# "Bldjid" plugin for Tkabber. 2009-04-07 v. 0.5.8
+# "Bldjid" plugin for Tkabber. 2009-04-07 v. 0.5.9
 # Written by Serge Yudin xmpp:bigote at jabber.ru
 # See README file for usage.
 
 namespace eval bldjid {
+# A variable where the last query result is stored.
 	variable user_list
+# An array where all user entrances are stored.
 	global jids_by_chats
 
 		set winid 0
 		::msgcat::mcload [file join [file dirname [info script]] msgs]
 
 		hook::add generate_completions_hook \
-		[namespace current]::command_comps
+		[namespace current]::visitors_compls
 		hook::add chat_send_message_hook \
 		[namespace current]::handle_commands 17
 
@@ -58,7 +60,7 @@
 
 		custom::defvar options(log_length) 0 \
 			[::msgcat::mc "Max length of your JID list for each room. \
-			Empty field means unlimited. See README for details."] \
+			 Zero means unlimited. See README for details."] \
 			-type integer -group Bldjid
 
 }
@@ -97,14 +99,12 @@
 
 			if {[info exists jids_by_chats($group)]} {
 				if {$options(verbosity_level) == "min"} {
-					set tmp_user_list $jids_by_chats($group)
-					foreach item $tmp_user_list {
+					foreach item $jids_by_chats($group) {
 						if {[lindex $item 2] == $real_jid
 						&&  [lindex $item 1] == $nick} {
 							return
 						}
 					}
-					unset tmp_user_list
 				}
 			}
 # I turn off filtering here but leave the code just for any case
@@ -119,9 +119,9 @@
 				&& $options(log_length) > 0 \
 				&& [info exists jids_by_chats($group)]\
 				&& [llength $jids_by_chats($group)] >= $options(log_length)} {
-					set jids_by_chats($group) [lrange $jids_by_chats($group) \
-					[expr {[llength $jids_by_chats($group)]} \
-					- $options(log_length) + 1 ] end]
+					set jids_by_chats($group) [lreplace $jids_by_chats($group) 0 \
+					[expr {[llength $jids_by_chats($group)] \
+					- $options(log_length)}]]
 				}
 				lappend jids_by_chats($group) [list $ts $nick $real_jid]
 			}
@@ -138,13 +138,33 @@
 hook::add room_nickname_changed_hook \
 		[namespace current]::bldjid::smart_enter_exit_message 51
 
-proc bldjid::command_comps {chatid compsvar wordstart line} {
+## Thanks to Alexey Smirnov <alexey.smirnov at gmx.com>
+## Adapted by Serge Yudin.
+proc bldjid::visitors_compls {chatid compsvar wordstart line} {
+	variable user_list
+	set group [::xmpp::jid::stripResource [chat::get_jid $chatid]]
+	if {![::muc::is_compatible $group]} return
+
 	upvar 0 $compsvar comps
 
 	if {!$wordstart} {
-		lappend comps	{/bldjid } {/unbldjid } {/banjid } {/amnesty } \
-						{/visitors } {/visited } {/bldhelp }
+		lappend comps {/bldjid } {/unbldjid } {/banjid } {/amnesty } \
+					  {/visitors } {/visited } {/bldhelp }
 	}
+
+	if {($wordstart && [string match {/bldjid*} $line]) \
+	||  ($wordstart && [string match {/banjid*} $line]) \
+	||  ($wordstart && [string match {/unban*} $line]) \
+	||  ($wordstart && [string match {/unbldjid*} $line])} {
+		set jidcomps {}
+		foreach jid $user_list {
+			if {$jid != ""} {
+				lappend jidcomps [lindex $jid 2]
+			}
+		}
+		set jidcomps [lsort -dictionary -unique $jidcomps]
+		set comps [concat $jidcomps $comps]
+	}
 }
 
 proc bldjid::handle_commands {chatid user body type} {
@@ -550,7 +570,6 @@
 		}
 	}
 	if {![info exists grplist]} {
-#		chat::add_message $chatid $group error "Pattern $pattern has no match." {}
 		return stop
 	}
 	foreach tmpchatid $grplist {



More information about the Tkabber-dev mailing list