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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Apr 5 05:30:27 MSD 2009


Author: bigote
Date: 2009-04-05 05:30:26 +0400 (Sun, 05 Apr 2009)
New Revision: 195

Modified:
   trunk/plugins/bldjid/ChangeLog
   trunk/plugins/bldjid/README
   trunk/plugins/bldjid/TODO
   trunk/plugins/bldjid/bldjid.tcl
Log:
Group filtering works now, but it's a workaround: the plugin
still logs every room whether the filter option is set or not.
When it's set, _the_resulsts_ are filtered out. If you turn off
this option and repeat a /visit* command in a room without privileges,
it will show you a log.


Modified: trunk/plugins/bldjid/ChangeLog
===================================================================
--- trunk/plugins/bldjid/ChangeLog	2009-03-31 05:39:09 UTC (rev 194)
+++ trunk/plugins/bldjid/ChangeLog	2009-04-05 01:30:26 UTC (rev 195)
@@ -1,3 +1,31 @@
+2009-04-05  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
+
+--- Version 0.5 of the plugin.
+--- Files modified:
+    bldjid.tcl, TODO, README, ChangeLog.
+
+--- Changes:
+	Group filtering works now, but it's a workaround: the plugin
+	still logs every room whether the filter option is set or not.
+	When it's set, the resulsts are filtered out. If you turn off
+	this option and repeat a /visit* command in a room without privileges,
+	it will show you a log.
+
+--- Known problem:
+	A problem with room filtering described below (see version 0-4b6
+	description) seems to be too difficult to resolve, at least for me
+	and at least at the moment. It has nothing to do with hook priority
+	neither with the level of verbosity, etc. It happens because
+	always almost I'm the last to enter a populated room (more than
+	3-4 persons), so the script has to wait too long before the room is
+	fully populated. Usually the check begins when 3 users have already
+	entered.
+
+--- TODO:
+	Try to set a delay before checking admin privileges,
+	long enough	to let everybody (and myself!) enter the room.
+	Suggestions are welcome :)
+
 2009-03-31  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
 
 --- Version 0.4b6 of the plugin.

Modified: trunk/plugins/bldjid/README
===================================================================
--- trunk/plugins/bldjid/README	2009-03-31 05:39:09 UTC (rev 194)
+++ trunk/plugins/bldjid/README	2009-04-05 01:30:26 UTC (rev 195)
@@ -21,7 +21,7 @@
 
 Also a command is added to ban a user in the current room by his/her JID.
 The user is not necessarily has to be in the room at the moment.
-(Tkabber's command /ban only bans by nickname 
+(Tkabber's command /ban only bans by nickname
 and only if the user is still in the room).
 
 ---	Usage:
@@ -35,7 +35,7 @@
 and after a confirmation all outcasts from that room will be unbanned.
 
 
-New commands added that could be helpful 
+New commands added that could be helpful
 when ::muc::options(gen_enter_exit_msgs) is disabled.
 
 ---	Show all visitors of the current room
@@ -67,7 +67,7 @@
 	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 
+--- Autocompletion works for all these commands: write a couple
 	of the first letters of a command and hit TAB one of more times.
 
 =====================
@@ -82,22 +82,27 @@
 	Turns on JIDs gathering. ::muc::options(gen_enter_exit_msgs) must be disabled.
 	Commands /banjid, /bldjid, /unbldjid, /amnesty don't need it, however.
 
+--- ::plugins::bldjid::options(filter_admin_rooms)
+	If you don't want rooms where you don't have admin privileges
+	to be listed by /visit* commands, turn on this option (default setting).
+	Bldjid still gathers logs for such rooms, it just doesn't display them.
+
 --- ::plugins::bldjid::options(verbosity_level)
-	Minimum level means that there will be no repeated JIDs 
+	Minimum level means that there will be no repeated JIDs
 	in each room list and no timestamps.
-	Maximum level means that every entrance	of every user 
+	Maximum level means that every entrance	of every user
 	will be logged, with a corresponding timestamp.
 
 --- ::plugins::bldjid::options(send_chat_messages)
 	Besides of logging user entrances, chat system messages are published.
 	Unlike usual messages that are sent by ::muc::options(gen_enter_exit_msgs)
-	these only appear once per JID. That's why it only works 
+	these only appear once per JID. That's why it only works
 	if Minimum verbosity level is chosen. If not, if would be almost the same
 	as ::muc::options(gen_enter_exit_msgs) messages (without exit messages).
 
-If ::muc::options(gen_enter_exit_msgs) is enabled again, 
-no new entries are added to the existing list. However, 
-it's still kept alive to be consulted at any time. 
+If ::muc::options(gen_enter_exit_msgs) is enabled again,
+no new entries are added to the existing list. However,
+it's still kept alive to be consulted at any time.
 The option above only affects gathering new entries:
 they are put either to the list or to chat windows.
 

Modified: trunk/plugins/bldjid/TODO
===================================================================
--- trunk/plugins/bldjid/TODO	2009-03-31 05:39:09 UTC (rev 194)
+++ trunk/plugins/bldjid/TODO	2009-04-05 01:30:26 UTC (rev 195)
@@ -1,9 +1,5 @@
 === Plugin should be tested, new Customize options should be uncommented
 	and implemented, as the following:
---- options(filter_admin_rooms) is enabled now and it means
-	that you can only log user entrances in the rooms where you have
-	admin privileges. However, one might need to log all available rooms
-	although no JIDs will be available.
 --- options(log_length) means limit for the list for /visitors and /visited commands.
     How much? I have about 12 rooms and a couple of them are quite populated.
     So the list grows some 700 records a day. I think 3000 by default would be OK.
@@ -23,6 +19,9 @@
 === 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.
+
 ===	Add "Bldjid" menu item with all commands to room MUC menu.
 	Note that a list of rooms must be done for these commands to work.
 

Modified: trunk/plugins/bldjid/bldjid.tcl
===================================================================
--- trunk/plugins/bldjid/bldjid.tcl	2009-03-31 05:39:09 UTC (rev 194)
+++ trunk/plugins/bldjid/bldjid.tcl	2009-04-05 01:30:26 UTC (rev 195)
@@ -1,10 +1,10 @@
-# "Bldjid" plugin for Tkabber. 2009-03-31 v. 0.4b6
+# "Bldjid" plugin for Tkabber. 2009-04-05 v. 0.5
 # Written by Serge Yudin xmpp:bigote at jabber.ru
 # See README file for usage.
 
 namespace eval bldjid {
 	variable user_list
-		variable jids_by_chats
+	global jids_by_chats
 
 		set winid 0
 		::msgcat::mcload [file join [file dirname [info script]] msgs]
@@ -32,8 +32,9 @@
 			-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."] \
+			[::msgcat::mc "This option doesn't prevent logging\
+			in the rooms where you don't have admin privileges\
+			but it helps when showing results."] \
 			-type boolean -group Bldjid
 
 		custom::defvar options(verbosity_level) min \
@@ -70,22 +71,7 @@
 	} else {
 		return
 	}
-# TODO: Add check if the current group is valid 
-# in case options(filter_admin_rooms) is enabled
-#puts $xlib
-#	set v_groups [[namespace current]::valid_groups $xlib]
-#puts $v_groups
-#	if {$options(filter_admin_rooms)} {
-#puts [lsearch -exact $v_groups $group]
-#		if {[lsearch -exact $v_groups $group] < 0} {
-#			return stop
-#		}
-#	}
 
-#	set iam [lindex [whoami $xlib $group] 1]
-#	if {$iam == "" || !($iam == "admin" || $iam == "owner")} {
-#		return
-#	}
 	if {[::chat::is_opened $chatid]} {
 		if {[::chat::is_groupchat $chatid]} {
 			if {[::xmpp::jid::resource $jid] == ""} {
@@ -99,11 +85,8 @@
 			}
 			set real_jid [::xmpp::jid::stripResource \
 				[::muc::get_real_jid $xlib $group/$nick]]
-#            if {$real_jid == ""} {
-#                return
-#            }
-			variable jids_by_chats
 
+			global jids_by_chats
 			if {[info exists jids_by_chats($group)]} {
 				if {$options(verbosity_level) == "min"} {
 					set tmp_user_list $jids_by_chats($group)
@@ -116,7 +99,8 @@
 					unset tmp_user_list
 				}
 			}
-			if {$options(filter_admin_rooms)} {
+# I turn off filtering here but leave the code just for any case
+			if {0 && $options(filter_admin_rooms)} {
 				set iam [lindex [whoami $xlib $group] 1]
 				if {($iam == "admin" || $iam == "owner")} {
 					lappend jids_by_chats($group) [list $ts $nick $real_jid]
@@ -145,6 +129,10 @@
 }
 
 proc bldjid::handle_commands {chatid user body type} {
+	set list_doesn_exist "List for the requested room doesn't exist.\
+		Make sure you provide a full room's JID or check if the plugin is turned on."
+	set filter_turned_on "You turned off showing results in the rooms\
+		where you don't have admin privileges."
 	variable user_list
 # Detect the command.
 	if {[string match {/bldjid*} $body]} {
@@ -255,7 +243,7 @@
 				::muc::options(gen_enter_exit_msgs) is enabled." {}
 				return stop
 			}
-			variable jids_by_chats
+			global jids_by_chats
 			set user_list {}
 			if {$room == ""} {
 				set room $group
@@ -263,21 +251,19 @@
 			} else {
 				set header "Show all visits to room $room:"
 			}
+			if {$options(filter_admin_rooms)} {
+				set iam [lindex [whoami $xlib $room] 1]
+				if {!($iam == "admin" || $iam == "owner")} {
+					chat::add_message $chatid $group error $filter_turned_on {}
+					return stop
+				}
+			}
 
-			if {[info exists jids_by_chats($room)]} {
-				set user_list $jids_by_chats($room)
-			} elseif {$options(filter_admin_rooms)} {
-				chat::add_message $chatid $group error \
-				"You turned off logging in the rooms\
-				where you don't have admin privileges." {}
+			if {![info exists jids_by_chats($room)]} {
+				chat::add_message $chatid $group error $list_doesnt_exist {}
 				return stop
-			} else {
-				chat::add_message $chatid $group error \
-				"List for room '$room' doesn't exist. \
-				Make sure you provide a full room's JID\
-				or check if the plugin is turned on." {}
-				return stop
 			}
+			set user_list $jids_by_chats($room)
 			set msg ""
 			set n 0
 			chat::add_message $chatid $group error $header {}
@@ -298,7 +284,7 @@
 				return stop
 			}
 
-			variable jids_by_chats
+			global jids_by_chats
 			set user_list {}
 			if {$nick == ""} {
 				chat::add_message $chatid $group error \
@@ -323,25 +309,23 @@
 					}
 				}
 			} else {
-				set header "Show visits of $nick to room $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
-						}
+				set header "Show visits of $nick to the room $room:"
+				if {$options(filter_admin_rooms)} {
+					set iam [lindex [whoami $xlib $group] 1]
+					if {!($iam == "admin" || $iam == "owner")} {
+						chat::add_message $chatid $group error $filter_turned_on {}
+						return stop
 					}
-				} elseif {$options(filter_admin_rooms)} {
-					chat::add_message $chatid $group error \
-					"You turned off logging in the rooms\
-					where you don't have admin privileges." {}
+				}
+				if {![info exists jids_by_chats($room)]} {
+					chat::add_message $chatid $group error $list_doesnt_exist {}
 					return stop
-				} else {
-					chat::add_message $chatid $group error \
-					"List for room '$room' doesn't exist. \
-					Make sure you provide a full room's JID\
-					or check if the plugin is turned on." {}
-					return stop
 				}
+				foreach item $jids_by_chats($room) {
+					if {[string equal [lindex $item 1] $nick]} {
+						lappend user_list $item
+					}
+				}
 			}
 			set msg ""
 			set n 0
@@ -383,7 +367,10 @@
 			\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)." {}
+			\nSome reason for banning (optional).\
+			\n\nSee README file for more information.\
+			\nVisit Tkabber -> Customize -> Plugins -> Bldjid\
+			\nto tune the plugin for your needs." {}
 		}
 	}
 	return stop
@@ -497,7 +484,7 @@
 		set chatid [chat::chatid $xlib $where]
 		set jid $where/[get_our_groupchat_nick $chatid]
 		return [list $muc::users(role,$xlib,$jid) \
-						 $muc::users(affiliation,$xlib,$jid)]
+				$muc::users(affiliation,$xlib,$jid)]
 	}
 }
 
@@ -555,7 +542,9 @@
 	set sep "||"
 	set x 0
 	foreach item $msg {
-		if {$item != ""} {
+		if {$item == ""} {
+			set item " "
+		}
 			if {$x == 0} {
 				set item $item
 			} else {
@@ -563,9 +552,7 @@
 			}
 			append newmsg $item
 			incr x
-		}
 	}
 	set NEWmsg [join [linsert $newmsg 0 "\n$n:\t"]]
 	return $NEWmsg
 }
-



More information about the Tkabber-dev mailing list