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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Mon Mar 30 02:48:37 MSD 2009


Author: bigote
Date: 2009-03-30 02:48:37 +0400 (Mon, 30 Mar 2009)
New Revision: 184

Modified:
   trunk/plugins/bldjid/ChangeLog
   trunk/plugins/bldjid/README
   trunk/plugins/bldjid/bldjid.tcl
Log:
Commands /visit* now generate their user lists in the same fashion as /bldhelp.
Added separators between items in user list for more readability.
Command /visited without parameters won't give results any longer.
One really doesn't need to see all entrances in all rooms.


Modified: trunk/plugins/bldjid/ChangeLog
===================================================================
--- trunk/plugins/bldjid/ChangeLog	2009-03-29 04:04:44 UTC (rev 183)
+++ trunk/plugins/bldjid/ChangeLog	2009-03-29 22:48:37 UTC (rev 184)
@@ -1,3 +1,16 @@
+2009-03-30	Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
+
+--- Version 0.4a6 of the plugin.
+--- Files modified:
+    bldjid.tcl, README, ChangeLog.
+
+--- Changes:
+	Variable $jids renamed to $user_list for it's more adequate.
+	Commands /visit* now generate their user lists in the same fashion as /bldhelp.
+	Added separators between items in user list for more readability.
+	Command /visited without parameters won't give results any longer.
+	One really doesn't need to see all entrances in all rooms.
+
 2009-03-29  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
 
 --- Version 0.4a5 of the plugin.

Modified: trunk/plugins/bldjid/README
===================================================================
--- trunk/plugins/bldjid/README	2009-03-29 04:04:44 UTC (rev 183)
+++ trunk/plugins/bldjid/README	2009-03-29 22:48:37 UTC (rev 184)
@@ -44,9 +44,6 @@
 ---	Show all visitors of rooms that match *room*
 /visitors room
 
----	Show all visits to all rooms
-/visited
-
 ---	Show visits made by someone whose nick or JID matches *nick*
 /visited nick
 

Modified: trunk/plugins/bldjid/bldjid.tcl
===================================================================
--- trunk/plugins/bldjid/bldjid.tcl	2009-03-29 04:04:44 UTC (rev 183)
+++ trunk/plugins/bldjid/bldjid.tcl	2009-03-29 22:48:37 UTC (rev 184)
@@ -1,10 +1,9 @@
-# "Bldjid" plugin for Tkabber. 2009-03-28 v. 0.4a5
+# "Bldjid" plugin for Tkabber. 2009-03-30 v. 0.4a6
 # Written by Serge Yudin xmpp:bigote at jabber.ru
 # See README file for usage.
 
-
 namespace eval bldjid {
-	variable jids
+	variable user_list
 	variable jids_by_chats
 
 	set winid 0
@@ -100,10 +99,11 @@
 			variable jids_by_chats
 
            	if {[info exists jids_by_chats($group)]} {
-               	set jids $jids_by_chats($group)
-				foreach item $jids {
+               	set tmp_user_list $jids_by_chats($group)
+				foreach item $tmp_user_list {
 					if {$options(verbosity_level) == "min"} {
 	                	if {[lsearch -exact [lindex $item 2] $real_jid] >= 0} {
+							unset tmp_user_list
     	                	return stop
         	        	}
 					}
@@ -131,7 +131,7 @@
 }
 
 proc bldjid::handle_commands {chatid user body type} {
-	variable jids
+	variable user_list
     # Detect the command.
     if {[string match {/bldjid*} $body]} {
         set cmd /bldjid
@@ -178,7 +178,7 @@
 	} else {
     	return stop
     }
-	
+
 	switch -- $cmd {
 		/unbldjid {
 		    foreach group $groupjids {
@@ -187,7 +187,7 @@
 		}
 
 		/bldjid {
-			if {[string is integer $jid] && [info exists jids]} {
+			if {[string is integer $jid] && [info exists user_list]} {
 				set jid [[namespace current]::pickup $jid $chatid]
 			}
 			if {$jid != ""} {
@@ -199,7 +199,7 @@
 		}
 
 		/banjid {
-            if {[string is integer $jid] && [info exists jids]} {
+            if {[string is integer $jid] && [info exists user_list]} {
                 set jid [[namespace current]::pickup $jid $chatid]
             }
 			if {$jid != ""} {
@@ -208,7 +208,7 @@
 					$xlib $group $params $jid $reason
 			}
 		}
-		
+
 		/amnesty {
 			set group [chat::get_jid $chatid]
 	    	variable winid
@@ -231,12 +231,11 @@
 			pack $w.lsure -expand yes -fill both
 			$w draw
 		}
-		
+
 		/visitors {
-			variable jids
 			variable jids_by_chats
 			set group [chat::get_jid $chatid]
-			set jids {}
+			set user_list {}
 			if {$room == ""} {
 				set room $group
 				set header "Show all visits to the current room:"
@@ -245,7 +244,7 @@
 			}
 
 			if {[info exists jids_by_chats($room)]} {
-				set jids $jids_by_chats($room) 
+				set user_list $jids_by_chats($room)
 			} else {
 				chat::add_message $chatid $group error \
 				"Room '$room' doesn't exist. Make sure you provide a full room's JID." {}
@@ -253,22 +252,21 @@
 			}
 	        set n 0
 			chat::add_message $chatid $group error $header {}
-			foreach msg $jids {
-   				chat::add_message $chatid $group info "$n: [join $msg]" {}
+			foreach user $user_list {
+				lappend msg [[namespace current]::format_msg $user $n]
 				incr n
 			}
+			chat::add_message $chatid $group info "[join $msg]" {}
 		}
 
         /visited {
 	        variable jids_by_chats
-    	    variable jids
         	set group [chat::get_jid $chatid]
-	        set jids {}
+	        set user_list {}
 
 			if {$nick == ""} {
-				set header "Show all visits to all rooms:"
-set jids "Not implemented yet."
-# TODO: add this stuff.
+				chat::add_message $chatid $group error \
+				"Parameters expected. Type /bldhelp for usage examples." {}
 			} elseif {$room == ""} {
 				set header "Show visits of $nick to all rooms:"
 				set groupjids [[namespace current]::valid_groups $xlib]
@@ -277,7 +275,7 @@
                     	foreach item $jids_by_chats($grp) {
 							if {[string equal [lindex $item 1] $nick]} {
 								lappend item $grp
-    	                    	lappend jids $item
+    	                    	lappend user_list $item
 							}
 						}
        	            }
@@ -287,7 +285,7 @@
 	            if {[info exists jids_by_chats($room)]} {
 					foreach item $jids_by_chats($room) {
 						if {[string equal [lindex $item 1] $nick]} {
-       		        		lappend jids $item
+       		        		lappend user_list $item
 						}
 					}
 	            } else {
@@ -299,10 +297,11 @@
 			}
 			set n 0
 			chat::add_message $chatid $group error $header {}
-    	    foreach msg $jids {
-        	    chat::add_message $chatid $group info "$n: [join $msg]" {}
-				incr n
-	        }
+            foreach user $user_list {
+                lappend msg [[namespace current]::format_msg $user $n]
+                incr n
+            }
+            chat::add_message $chatid $group info "[join $msg]" {}
         }
 
 		/bldhelp {
@@ -324,8 +323,6 @@
 			\n/visitors\
 			\n\nShow all visitors of rooms that match *room*:\
 			\n/visitors room\
-			\n\nShow all visits to all rooms:\
-			\n/visited\
 			\n\nShow visits made by someone whose nick or JID matches *nick*:\
 			\n/visited nick\
 			\n\nShows visits made by *nick*, to the rooms that match *room*:\
@@ -459,9 +456,9 @@
 }
 
 proc bldjid::valid_groups {xlib} {
-	# Filter out wrong conferences. 
+	# Filter out wrong conferences.
 	# We assume IRC-channels have to have "irc" part in their transport name.
-	# If some transport doesn't have it (1% of probability), 
+	# If some transport doesn't have it (1% of probability),
 	# a ban request will be sent there and we'll get an error.
 	set grpjids ""
     foreach tmpchatid [lsort [lfilter chat::is_groupchat [chat::opened $xlib]]] {
@@ -476,9 +473,9 @@
 }
 
 proc bldjid::pickup {index chatid} {
-	variable jids
+	variable user_list
     set group [chat::get_jid $chatid]
-   	set maxindex [expr {[llength $jids] - 1}]
+   	set maxindex [expr {[llength $user_list] - 1}]
     if {$maxindex < 0} {
    		# Nothing to show: list is empty. There's a check for it up there, however.
    	    chat::add_message $chatid $group error "The list is empty." {}
@@ -487,7 +484,7 @@
 		chat::add_message $chatid $group error "Index out of range." {}
 		return stop
 	} else {
-		set jid [lindex [lindex $jids $index] 2]
+		set jid [lindex [lindex $user_list $index] 2]
 		return $jid
 #		if {$jid != ""} {
 #			set ci [chat::input_win $chatid]
@@ -496,3 +493,20 @@
 	}
 }
 
+proc bldjid::format_msg {msg n} {
+	set sep "\|\|"
+	set x 0
+	foreach item $msg {
+		if {$item != ""} {
+			if {$x == 0} {
+				set item "\ $item"
+			} else {
+				set item "\ $sep\ $item"
+			}
+			append newmsg $item
+			incr x
+		}
+	}
+	set NEWmsg [join [linsert $newmsg 0 "\n$n:"]]
+	return $NEWmsg
+}



More information about the Tkabber-dev mailing list