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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Mon Mar 30 03:34:11 MSD 2009


Author: bigote
Date: 2009-03-30 03:34:11 +0400 (Mon, 30 Mar 2009)
New Revision: 186

Modified:
   trunk/plugins/bldjid/bldjid.tcl
Log:
Code formatting normalized.


Modified: trunk/plugins/bldjid/bldjid.tcl
===================================================================
--- trunk/plugins/bldjid/bldjid.tcl	2009-03-29 22:52:57 UTC (rev 185)
+++ trunk/plugins/bldjid/bldjid.tcl	2009-03-29 23:34:11 UTC (rev 186)
@@ -4,46 +4,46 @@
 
 namespace eval bldjid {
 	variable user_list
-	variable jids_by_chats
+		variable jids_by_chats
 
-	set winid 0
-    ::msgcat::mcload [file join [file dirname [info script]] msgs]
+		set winid 0
+		::msgcat::mcload [file join [file dirname [info script]] msgs]
 
-    hook::add generate_completions_hook \
-        [namespace current]::command_comps
-    hook::add chat_send_message_hook \
-        [namespace current]::handle_commands 17
+		hook::add generate_completions_hook \
+		[namespace current]::command_comps
+		hook::add chat_send_message_hook \
+		[namespace current]::handle_commands 17
 
 # Set plugin options.
-    set verbosity [list \
-                    min [::msgcat::mc "Minimum:\
-                    Log each entrance of a user\
-                    only once per room (less memory used)."]]
+		set verbosity [list \
+		min [::msgcat::mc "Minimum:\
+		Log each entrance of a user\
+		only once per room (less memory used)."]]
 #					max [::msgcat::mc "Maximum: Also log timestamps\
 #                    (all entrances of each user will be logged)."]]
 
-    custom::defgroup Plugins [::msgcat::mc "Plugins options."] -group Tkabber
+		custom::defgroup Plugins [::msgcat::mc "Plugins options."] -group Tkabber
 
-    custom::defgroup Bldjid [::msgcat::mc "Bldjid options."] -group Plugins
+		custom::defgroup Bldjid [::msgcat::mc "Bldjid options."] -group Plugins
 
-    custom::defvar options(enabled) 1 \
-        [::msgcat::mc "Enable JIDs logging (only works if\
-        ::muc::options(gen_enter_exit_msgs) is disabled)."] \
-        -type boolean -group Bldjid
+		custom::defvar options(enabled) 1 \
+		[::msgcat::mc "Enable JIDs logging (only works if\
+		::muc::options(gen_enter_exit_msgs) is disabled)."] \
+		-type boolean -group Bldjid
 
 #    custom::defvar options(filter_admin_rooms) 1 \
 #        [::msgcat::mc "Only will log JIDs in the rooms where you have\
 #        admin privileges."] \
 #        -type boolean -group Bldjid
 
-    custom::defvar options(verbosity_level) min \
-        [::msgcat::mc "Verbosity level."] \
-        -type radio -group Bldjid -layout vertical -values $verbosity
+		custom::defvar options(verbosity_level) min \
+		[::msgcat::mc "Verbosity level."] \
+		-type radio -group Bldjid -layout vertical -values $verbosity
 
-        custom::defvar options(send_chat_messages) 0 \
-            [::msgcat::mc "Generate and send to chats smart system messages\
-            about user entrances (will only work with Minimum verbosity level)."] \
-            -type boolean -group Bldjid
+		custom::defvar options(send_chat_messages) 0 \
+		[::msgcat::mc "Generate and send to chats smart system messages\
+		about user entrances (will only work with Minimum verbosity level)."] \
+		-type boolean -group Bldjid
 
 #    custom::defvar options(log_length) 3000 \
 #        [::msgcat::mc "Max length of your JID list. Empty field means unlimited."] \
@@ -56,13 +56,13 @@
 ## Adapted to bldjid's necessities by Serge Yudin
 proc bldjid::smart_enter_exit_message {xlib jid type x args} {
 	variable options
-	if {!($options(enabled) && !$::muc::options(gen_enter_exit_msgs))} {
+		if {!($options(enabled) && !$::muc::options(gen_enter_exit_msgs))} {
+			return stop
+		}
+	if {$type != "available"} {
 		return stop
 	}
-    if {$type != "available"} {
-        return stop
-    }
-    set group [::xmpp::jid::stripResource $jid]
+	set group [::xmpp::jid::stripResource $jid]
 # TODO: Add check if the current group is valid 
 # in case options(filter_admin_rooms) is enabled
 #puts $xlib
@@ -79,17 +79,17 @@
 #	if {$iam == "" || !($iam == "admin" || $iam == "owner")} {
 #		return
 #	}
-    set chatid [::chat::chatid $xlib $group]
-    if {[::chat::is_opened $chatid]} {
-        if {[::chat::is_groupchat $chatid]} {
-            if {[::xmpp::jid::resource $jid] == ""} {
-                return stop
-            }
-            set nick [::chat::get_nick $xlib $jid groupchat]
+	set chatid [::chat::chatid $xlib $group]
+	if {[::chat::is_opened $chatid]} {
+		if {[::chat::is_groupchat $chatid]} {
+			if {[::xmpp::jid::resource $jid] == ""} {
+				return stop
+			}
+			set nick [::chat::get_nick $xlib $jid groupchat]
 			set ts ""
 			if {$options(verbosity_level) != "min"} {
 				set ts [clock format [clock seconds] \
-				-format $::plugins::options(timestamp_format)]
+					-format $::plugins::options(timestamp_format)]
 			}
 			set real_jid [::xmpp::jid::stripResource \
 				[::muc::get_real_jid $xlib $group/$nick]]
@@ -98,45 +98,45 @@
 #            }
 			variable jids_by_chats
 
-           	if {[info exists jids_by_chats($group)]} {
-               	set tmp_user_list $jids_by_chats($group)
+			if {[info exists jids_by_chats($group)]} {
+				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} {
+						if {[lsearch -exact [lindex $item 2] $real_jid] >= 0} {
 							unset tmp_user_list
-    	                	return stop
-        	        	}
+							return stop
+						}
 					}
 				}
-           	}
-           	lappend jids_by_chats($group) [list $ts $nick $real_jid]
+			}
+			lappend jids_by_chats($group) [list $ts $nick $real_jid]
 			if {$options(send_chat_messages) && $options(verbosity_level) == "min"} {
-            	set occupant "$nick ($real_jid)"
-   	        	set msg [::msgcat::mc "%s has entered" $occupant]
-       	    	::chat::add_message $chatid $group groupchat $msg {}
+				set occupant "$nick ($real_jid)"
+				set msg [::msgcat::mc "%s has entered" $occupant]
+				::chat::add_message $chatid $group groupchat $msg {}
 			}
 		}
-    }
+	}
 }
 hook::add client_presence_hook \
-    [namespace current]::bldjid::smart_enter_exit_message 98
+		[namespace current]::bldjid::smart_enter_exit_message 98
 
 proc bldjid::command_comps {chatid compsvar wordstart line} {
-    upvar 0 $compsvar comps
+	upvar 0 $compsvar comps
 
-    if {!$wordstart} {
-        lappend comps {/bldjid } {/unbldjid } {/banjid } {/amnesty } \
-		{/visitors } {/visited } {/bldhelp }
-    }
+	if {!$wordstart} {
+		lappend comps	{/bldjid } {/unbldjid } {/banjid } {/amnesty } \
+						{/visitors } {/visited } {/bldhelp }
+	}
 }
 
 proc bldjid::handle_commands {chatid user body type} {
 	variable user_list
-    # Detect the command.
-    if {[string match {/bldjid*} $body]} {
-        set cmd /bldjid
-    } elseif {[string match {/unbldjid*} $body]} {
-        set cmd /unbldjid
+# Detect the command.
+	if {[string match {/bldjid*} $body]} {
+		set cmd /bldjid
+	} elseif {[string match {/unbldjid*} $body]} {
+		set cmd /unbldjid
 	} elseif {[string match {/banjid*} $body]} {
 		set cmd /banjid
 	} elseif {[string match {/amnesty*} $body]} {
@@ -144,25 +144,25 @@
 	} elseif {[string match {/visitors*} $body]} {
 		set cmd /visitors
 	} elseif {[string match {/visited*} $body]} {
-        set cmd /visited
+		set cmd /visited
 	} elseif {[string match {/bldhelp*} $body]} {
-	    set cmd /bldhelp
-    } else return
+		set cmd /bldhelp
+	} else return
 
-    if {$type != "groupchat"} return
+	if {$type != "groupchat"} return
 
-    set xlib [chat::get_xlib $chatid]
-    set groupjids [[namespace current]::valid_groups $xlib]
-   	set room ""
-   	set nick ""
-   	if {[string equal [string range $body 0 9] "/unbldjid "]} {
-       	set jid [muc::parse_nick $body 10]
-   	} elseif {[string equal [string range $body 0 7] "/bldjid "]} {
-        lassign [muc::parse_nick_reason $body 8] jid reason
-        set params {affiliation outcast}
+	set xlib [chat::get_xlib $chatid]
+	set groupjids [[namespace current]::valid_groups $xlib]
+	set room ""
+	set nick ""
+	if {[string equal [string range $body 0 9] "/unbldjid "]} {
+		set jid [muc::parse_nick $body 10]
+	} elseif {[string equal [string range $body 0 7] "/bldjid "]} {
+		lassign [muc::parse_nick_reason $body 8] jid reason
+		set params {affiliation outcast}
 	} elseif {[string equal [string range $body 0 7] "/banjid "]} {
-        lassign [muc::parse_nick_reason $body 8] jid reason
-        set params {affiliation outcast}
+		lassign [muc::parse_nick_reason $body 8] jid reason
+		set params {affiliation outcast}
 	} elseif {[string equal [string range $body 0 7] "/amnesty"]} {
 		set attr affiliation
 		set val outcast
@@ -170,19 +170,19 @@
 		if {[string index $body 9] == " " && [string length $body] > 10} {
 			set room [muc::parse_nick $body 10]
 		}
-    } elseif {[string equal [string range $body 0 7] "/visited"]} {
-        if {[string index $body 8] == " " && [string length $body] > 9} {
+	} elseif {[string equal [string range $body 0 7] "/visited"]} {
+		if {[string index $body 8] == " " && [string length $body] > 9} {
 			lassign [muc::parse_nick_reason $body 9] nick room
-        }
+		}
 	} elseif {[string equal [string range $body 0 7] "/bldhelp"]} {
 	} else {
-    	return stop
-    }
+		return stop
+	}
 
 	switch -- $cmd {
 		/unbldjid {
-		    foreach group $groupjids {
-    	       	muc::unban $xlib $group $jid
+			foreach group $groupjids {
+				muc::unban $xlib $group $jid
 			}
 		}
 
@@ -199,37 +199,37 @@
 		}
 
 		/banjid {
-            if {[string is integer $jid] && [info exists user_list]} {
-                set jid [[namespace current]::pickup $jid $chatid]
-            }
+			if {[string is integer $jid] && [info exists user_list]} {
+				set jid [[namespace current]::pickup $jid $chatid]
+			}
 			if {$jid != ""} {
 				set group [chat::get_jid $chatid]
-    	    	[namespace current]::send_ban_request \
-					$xlib $group $params $jid $reason
+				[namespace current]::send_ban_request \
+				$xlib $group $params $jid $reason
 			}
 		}
 
 		/amnesty {
 			set group [chat::get_jid $chatid]
-	    	variable winid
-		    set w .amn$winid
-    		incr winid
-		    if {[winfo exists $w]} {
-    		    destroy $w
-	    	}
-		    Dialog $w -title [::msgcat::mc "Forgive all outcasts here?"]] \
-    		    -modal none -separator 1 -anchor e -default 0 -cancel 1 \
-        		-parent .
-		    set f [$w getframe]
-    		$w add -text [::msgcat::mc "OK"] \
-        		-command [list [namespace current]::amnesty $chatid $attr $val $w $f]
-		    $w add -text [::msgcat::mc "Cancel"] -command [list destroy $w]
+			variable winid
+			set w .amn$winid
+			incr winid
+			if {[winfo exists $w]} {
+				destroy $w
+			}
+			Dialog $w -title [::msgcat::mc "Forgive all outcasts here?"]] \
+				-modal none -separator 1 -anchor e -default 0 -cancel 1 \
+				-parent .
+				set f [$w getframe]
+				$w add -text [::msgcat::mc "OK"] \
+				-command [list [namespace current]::amnesty $chatid $attr $val $w $f]
+				$w add -text [::msgcat::mc "Cancel"] -command [list destroy $w]
 
-			label $w.lsure -padx 10 -pady 5 \
-			-text "Are you sure you want to unban all outcasts in this room?\n\
-			   There will be no backup: you're either kind-hearted or not ;)"
-			pack $w.lsure -expand yes -fill both
-			$w draw
+				label $w.lsure -padx 10 -pady 5 \
+				-text "Are you sure you want to unban all outcasts in this room?\n\
+				There will be no backup: you're either kind-hearted or not ;)"
+				pack $w.lsure -expand yes -fill both
+				$w draw
 		}
 
 		/visitors {
@@ -250,7 +250,7 @@
 				"Room '$room' doesn't exist. Make sure you provide a full room's JID." {}
 				return stop
 			}
-	        set n 0
+			set n 0
 			chat::add_message $chatid $group error $header {}
 			foreach user $user_list {
 				lappend msg [[namespace current]::format_msg $user $n]
@@ -259,11 +259,10 @@
 			chat::add_message $chatid $group info "[join $msg]" {}
 		}
 
-        /visited {
-	        variable jids_by_chats
-        	set group [chat::get_jid $chatid]
-	        set user_list {}
-
+		/visited {
+			variable jids_by_chats
+			set group [chat::get_jid $chatid]
+			set user_list {}
 			if {$nick == ""} {
 				chat::add_message $chatid $group error \
 				"Parameters expected. Type /bldhelp for usage examples." {}
@@ -272,37 +271,37 @@
 				set groupjids [[namespace current]::valid_groups $xlib]
 				foreach grp $groupjids {
 					if {[info exists jids_by_chats($grp)]} {
-                    	foreach item $jids_by_chats($grp) {
+						foreach item $jids_by_chats($grp) {
 							if {[string equal [lindex $item 1] $nick]} {
 								lappend item $grp
-    	                    	lappend user_list $item
+								lappend user_list $item
 							}
 						}
-       	            }
+					}
 				}
 			} else {
 				set header "Show visits of $nick to room $room:"
-	            if {[info exists jids_by_chats($room)]} {
+				if {[info exists jids_by_chats($room)]} {
 					foreach item $jids_by_chats($room) {
 						if {[string equal [lindex $item 1] $nick]} {
-       		        		lappend user_list $item
+							lappend user_list $item
 						}
 					}
-	            } else {
-       		        chat::add_message $chatid $group error \
-               		"Room '$room' doesn't exist. \
+				} else {
+					chat::add_message $chatid $group error \
+					"Room '$room' doesn't exist. \
 					Make sure you provide a full room's JID." {}
-       		        return stop
-	            }
+					return stop
+				}
 			}
 			set n 0
 			chat::add_message $chatid $group error $header {}
-            foreach user $user_list {
-                lappend msg [[namespace current]::format_msg $user $n]
-                incr n
-            }
-            chat::add_message $chatid $group info "[join $msg]" {}
-        }
+			foreach user $user_list {
+				lappend msg [[namespace current]::format_msg $user $n]
+				incr n
+			}
+			chat::add_message $chatid $group info "[join $msg]" {}
+		}
 
 		/bldhelp {
 			set group [chat::get_jid $chatid]
@@ -328,121 +327,116 @@
 			\n\nShows visits made by *nick*, to the rooms that match *room*:\
 			\n/visited nick\
 			\nroom\
-            \n\nBan in all rooms where you have admin privileges:\
+			\n\nBan in all rooms where you have admin privileges:\
 			\n?n? means an item number from a list given by a /visit* command.\
-            \n/bldjid ?n?\
-            \nSome reason for banning (optional).\
-            \n\nBan in the current room by a number from a list given by a /visit* command.\
-            \n/banjid ?n?\
-            \nSome reason for banning (optional)." {}
+			\n/bldjid ?n?\
+			\nSome reason for banning (optional).\
+			\n\nBan in the current room by a number from a list given by a /visit* command.\
+			\n/banjid ?n?\
+			\nSome reason for banning (optional)." {}
 		}
 	}
-    return stop
+	return stop
 }
 
-proc bldjid::confirm_ban {xlib group params jid reason w} {
-	destroy $w
-	[namespace current]::send_ban_request $xlib $group $params $jid $reason
-}
-
 proc bldjid::send_ban_request {xlib group params jid reason} {
 	set itemsubtags {}
 	if {$reason != ""} {
-	    lappend itemsubtags [::xmpp::xml::create reason -cdata $reason]
+		lappend itemsubtags [::xmpp::xml::create reason -cdata $reason]
 	}
 	set vars [list jid $jid]
 	set item [::xmpp::xml::create item \
-        -attrs [concat $vars $params] \
-        -subelements $itemsubtags]
-	::xmpp::sendIQ $xlib set \
-    	-query [::xmpp::xml::create query \
-        -xmlns $::NS(muc#admin) \
-        -subelement $item] \
-	    -to $group \
-    	-command [list [namespace current]::test_error_res "$params \'$jid\'" $xlib $group]
+		-attrs [concat $vars $params] \
+		-subelements $itemsubtags]
+		::xmpp::sendIQ $xlib set \
+		-query [::xmpp::xml::create query \
+		-xmlns $::NS(muc#admin) \
+		-subelement $item] \
+		-to $group \
+		-command [list [namespace current]::test_error_res "$params \'$jid\'" $xlib $group]
 }
 
 proc bldjid::test_error_res {op xlib group res child} {
-        set chatid [chat::chatid $xlib $group]
-    if {![string equal $res ok]} {
-        chat::add_message $chatid $group error \
-            [format "%s: %s" $op [error_to_string $child]] {}
-    } else {
+	set chatid [chat::chatid $xlib $group]
+	if {![string equal $res ok]} {
+		chat::add_message $chatid $group error \
+		[format "%s: %s" $op [error_to_string $child]] {}
+	} else {
 		chat::add_message $chatid $group info \
-			[format "%s: %s" $op "User is banned"] {}
+		[format "%s: %s" $op "User is banned"] {}
 	}
 	return
 }
 
 proc bldjid::amnesty {chatid attr val w f} {
 	set group [chat::get_jid $chatid]
-	request_list $attr $val $chatid
+	[namespace current]::request_list $attr $val $chatid
 	destroy $w
 }
 
 proc bldjid::request_list {attr val chatid} {
-    set xlib [chat::get_xlib $chatid]
-    set group [chat::get_jid $chatid]
-    ::xmpp::sendIQ $xlib get \
-        -query [::xmpp::xml::create query \
-                        -xmlns $::NS(muc#admin) \
-                        -subelement [::xmpp::xml::create item \
-                                        -attrs [list $attr $val]]] \
-        -to $group \
-        -command [list [namespace current]::receive_send_list $attr $val $chatid]
+	set xlib [chat::get_xlib $chatid]
+	set group [chat::get_jid $chatid]
+	::xmpp::sendIQ $xlib get \
+		-query [::xmpp::xml::create query \
+		-xmlns $::NS(muc#admin) \
+		-subelement [::xmpp::xml::create item \
+		-attrs [list $attr $val]]] \
+		-to $group \
+		-command [list [namespace current]::receive_send_list $attr $val $chatid]
 }
 
 proc bldjid::receive_send_list {attr val chatid res child} {
-    set xlib [chat::get_xlib $chatid]
-    set group [chat::get_jid $chatid]
-    if {![string equal $res ok]} {
-        chat::add_message $chatid $group error \
-            "$attr $val list: [error_to_string $child]" {}
-        return
-    }
-    ::xmpp::xml::split $child tag xmlns attrs cdata items
+	set xlib [chat::get_xlib $chatid]
+	set group [chat::get_jid $chatid]
+	if {![string equal $res ok]} {
+		chat::add_message $chatid $group error \
+		"$attr $val list: [error_to_string $child]" {}
+		return
+	}
+	::xmpp::xml::split $child tag xmlns attrs cdata items
 	if {$items == {}} {
 		chat::add_message $chatid $group error \
-        [::msgcat::mc "The blacklist is already empty for $group"] {}
+		[::msgcat::mc "The blacklist is already empty for $group"] {}
 		return
 	}
-    set items2 {}
-    foreach item $items {
-        ::xmpp::xml::split $item tag xmlns attrs cdata subels
-        switch -- $tag {
-            item {
-                set nick [::xmpp::xml::getAttr $attrs nick]
-                set jid [::xmpp::xml::getAttr $attrs jid]
-                set role [::xmpp::xml::getAttr $attrs role]
-                set affiliation [::xmpp::xml::getAttr $attrs affiliation]
-                set reason ""
-                foreach subitem $subels {
-                    ::xmpp::xml::split $subitem stag sxmlns sattrs scdata ssubels
-                    if {$stag == "reason"} {
-                        set reason $scdata
-                    }
-                }
+	set items2 {}
+	foreach item $items {
+		::xmpp::xml::split $item tag xmlns attrs cdata subels
+		switch -- $tag {
+			item {
+				set nick [::xmpp::xml::getAttr $attrs nick]
+				set jid [::xmpp::xml::getAttr $attrs jid]
+				set role [::xmpp::xml::getAttr $attrs role]
+				set affiliation [::xmpp::xml::getAttr $attrs affiliation]
+				set reason ""
+				foreach subitem $subels {
+					::xmpp::xml::split $subitem stag sxmlns sattrs scdata ssubels
+					if {$stag == "reason"} {
+						set reason $scdata
+					}
+				}
 				set itemsubtags {}
 				lappend itemsubtags [::xmpp::xml::create reason \
-							-cdata $reason]
+					-cdata $reason]
 				lappend items2 [::xmpp::xml::create item \
-                               -attrs "affiliation none jid $jid" \
-                               -subelements $itemsubtags]
-            }
-        }
-    }
-    if {$items2 != {}} {
-        ::xmpp::sendIQ $xlib set \
-            -query [::xmpp::xml::create query \
-                               -xmlns $::NS(muc#admin) \
-                               -subelements $items2] \
-            -to $group \
-            -command [list muc::test_error_res \
-                           [::msgcat::mc "Sending %s %s list" $attr $val] \
-                           $xlib $group]
-    }
-    chat::add_message $chatid $group info \
-        [::msgcat::mc "Thank you for your generosity! +10 to Reputation!"] {}
+					-attrs "affiliation none jid $jid" \
+					-subelements $itemsubtags]
+			}
+		}
+	}
+	if {$items2 != {}} {
+		::xmpp::sendIQ $xlib set \
+			-query [::xmpp::xml::create query \
+			-xmlns $::NS(muc#admin) \
+			-subelements $items2] \
+			-to $group \
+			-command [list muc::test_error_res \
+			[::msgcat::mc "Sending %s %s list" $attr $val] \
+			$xlib $group]
+	}
+	chat::add_message $chatid $group info \
+	[::msgcat::mc "Thank you for your generosity! +10 to Reputation!"] {}
 }
 
 # Here we get our role and affiliation in a room.
@@ -456,17 +450,17 @@
 }
 
 proc bldjid::valid_groups {xlib} {
-	# 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),
-	# a ban request will be sent there and we'll get an error.
+# 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),
+# 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]]] {
+	foreach tmpchatid [lsort [lfilter chat::is_groupchat [chat::opened $xlib]]] {
 		set tmpgrp [chat::get_jid $tmpchatid]
 		set iam [lindex [whoami $xlib $tmpgrp] 1]
 		if {($iam == "admin" || $iam == "owner") \
-		&&  ![string match *%*@irc* $tmpgrp]} {
-			 lappend grpjids $tmpgrp
+			&& ![string match *%*@irc* $tmpgrp]} {
+			lappend grpjids $tmpgrp
 		}
 	}
 	return $grpjids
@@ -474,13 +468,13 @@
 
 proc bldjid::pickup {index chatid} {
 	variable user_list
-    set group [chat::get_jid $chatid]
-   	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." {}
-       	return stop
-    } elseif {$index > $maxindex || $index < 0} {
+	set group [chat::get_jid $chatid]
+	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." {}
+		return stop
+	} elseif {$index > $maxindex || $index < 0} {
 		chat::add_message $chatid $group error "Index out of range." {}
 		return stop
 	} else {
@@ -489,7 +483,6 @@
 #		if {$jid != ""} {
 #			set ci [chat::input_win $chatid]
 #			after idle [list $ci insert end $cmd $jid\n]
-		}
 	}
 }
 
@@ -510,3 +503,4 @@
 	set NEWmsg [join [linsert $newmsg 0 "\n$n:"]]
 	return $NEWmsg
 }
+



More information about the Tkabber-dev mailing list