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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Mar 31 09:39:09 MSD 2009


Author: bigote
Date: 2009-03-31 09:39:09 +0400 (Tue, 31 Mar 2009)
New Revision: 194

Modified:
   trunk/plugins/bldjid/ChangeLog
   trunk/plugins/bldjid/TODO
   trunk/plugins/bldjid/bldjid.tcl
Log:
An attempt was made to make group filtering work (options(filter_admin_rooms)).
There is a little problem with it so if you don't want to get warnings
when entering rooms (only once per entering) please keep the previous version of plugin.
If you do not plan filtering out rooms where you have admin privileges,
you can use this version -- you should get warnings only when this option is enabled.
See ChangeLog for more details.


Modified: trunk/plugins/bldjid/ChangeLog
===================================================================
--- trunk/plugins/bldjid/ChangeLog	2009-03-31 00:34:16 UTC (rev 193)
+++ trunk/plugins/bldjid/ChangeLog	2009-03-31 05:39:09 UTC (rev 194)
@@ -1,5 +1,34 @@
 2009-03-31  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
 
+--- Version 0.4b6 of the plugin.
+--- Files modified:
+    bldjid.tcl, TODO, ChangeLog.
+
+--- Changes:
+	Some new aims added to TODO.
+
+	An attempt was made to make group filtering work (options(filter_admin_rooms)).
+
+--- Known problem:
+	It works but an error appears when entering a non-empty room.
+	After the warning is closed, the room gets filled up and everything works
+	nice. I suppose the problem is that hook client_presence_hook handler --
+	proc smart_enter_exit_message -- has a heigher priority (69)
+	than chat::change_presence (70) that was made to avoid logging every
+	single presence change (we are interested only in entrance logging).
+	Since smart_enter_exit_message is run before chat::change_presence
+	it cannot receive information about our role/affiliation in such room
+	until some time passes (which is a bit weird because when we enter
+	an empty room there's no error at all).
+	Anyway, I think that adding 'after idle' command would help,
+	but I haven't managed to do it right yet. So, any suggestion
+	will be appreciated :)
+
+	In spite of this inconvenience, this functionality seems to work well.
+	Testers are welcome.
+
+2009-03-31  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
+
 --- Version 0.4b5 of the plugin.
 --- Files modified:
     bldjid.tcl, ChangeLog.

Modified: trunk/plugins/bldjid/TODO
===================================================================
--- trunk/plugins/bldjid/TODO	2009-03-31 00:34:16 UTC (rev 193)
+++ trunk/plugins/bldjid/TODO	2009-03-31 05:39:09 UTC (rev 194)
@@ -12,9 +12,17 @@
 	of user list to your feelings. Now the separator is '||'
 	and it is set within plugin's code.
 
+=== Gather JIDs regardless of ::muc::options(gen_enter_exit_msgs) state.
+	It's useful if you want to clean chat window, so no JIDs will be lost.
+
 === Add matching rules for /visit* commands to be able processing
 	not only exact room and nick names.
 
+=== Add possibility to track nick changes when logging.
+
+=== Add autocompletion for JIDs when using /bldjid-like commands
+	after user list publishing. (Now Tkabber tries to insert present nicks).
+
 ===	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 00:34:16 UTC (rev 193)
+++ trunk/plugins/bldjid/bldjid.tcl	2009-03-31 05:39:09 UTC (rev 194)
@@ -1,4 +1,4 @@
-# "Bldjid" plugin for Tkabber. 2009-03-31 v. 0.4b5
+# "Bldjid" plugin for Tkabber. 2009-03-31 v. 0.4b6
 # Written by Serge Yudin xmpp:bigote at jabber.ru
 # See README file for usage.
 
@@ -27,23 +27,23 @@
 		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
+			[::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(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
+			[::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
+			[::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."] \
@@ -116,7 +116,14 @@
 					unset tmp_user_list
 				}
 			}
-			lappend jids_by_chats($group) [list $ts $nick $real_jid]
+			if {$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]
+				}
+			} else {
+				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]
@@ -159,7 +166,7 @@
 	if {$type != "groupchat"} return
 
 	set xlib [chat::get_xlib $chatid]
-	set groupjids [[namespace current]::valid_groups $xlib]
+	set groupjids [[namespace current]::valid_groups $xlib admin]
 	set room ""
 	set nick ""
 	if {[string equal [string range $body 0 9] "/unbldjid "]} {
@@ -240,6 +247,7 @@
 		}
 
 		/visitors {
+			variable options
 			set group [chat::get_jid $chatid]
 			if {$::muc::options(gen_enter_exit_msgs)} {
 				chat::add_message $chatid $group error \
@@ -258,9 +266,15 @@
 
 			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." {}
+				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\
+				"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
 			}
@@ -275,6 +289,7 @@
 		}
 
 		/visited {
+			variable options
 			set group [chat::get_jid $chatid]
 			if {$::muc::options(gen_enter_exit_msgs)} {
 				chat::add_message $chatid $group error \
@@ -291,7 +306,12 @@
 				return stop
 			} elseif {$room == ""} {
 				set header "Show visits of $nick to all rooms:"
-				set groupjids [[namespace current]::valid_groups $xlib]
+				set which all
+				if {$options(filter_admin_rooms)} {
+					set which admin
+					append header " (Group filtering is ON)"
+				}
+				set groupjids [[namespace current]::valid_groups $xlib $which]
 				foreach grp $groupjids {
 					if {[info exists jids_by_chats($grp)]} {
 						foreach item $jids_by_chats($grp) {
@@ -310,9 +330,15 @@
 							lappend user_list $item
 						}
 					}
+				} 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." {}
+					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\
+					"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
 				}
@@ -470,25 +496,35 @@
 	if {[muc::is_compatible $where]} {
 		set chatid [chat::chatid $xlib $where]
 		set jid $where/[get_our_groupchat_nick $chatid]
-		if {[lcontain $grouproster(users,$chatid) $jid]} {
-			return [list $muc::users(role,$xlib,$jid) \
+		return [list $muc::users(role,$xlib,$jid) \
 						 $muc::users(affiliation,$xlib,$jid)]
-		}
 	}
 }
 
-proc bldjid::valid_groups {xlib} {
+proc bldjid::valid_groups {xlib which} {
 # 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.
+	global grouproster
 	set grpjids ""
 	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
+		set jid $tmpgrp/[get_our_groupchat_nick $tmpchatid]
+		if {[lcontain $grouproster(users,$tmpchatid) $jid]} {
+			switch -- $which {
+				admin {
+					set iam [lindex [whoami $xlib $tmpgrp] 1]
+					if {($iam == "admin" || $iam == "owner") \
+						&& ![string match *%*@irc* $tmpgrp]} {
+						lappend grpjids $tmpgrp
+					}
+				}
+
+				all {
+					lappend grpjids $tmpgrp
+				}
+			}
 		}
 	}
 	return $grpjids



More information about the Tkabber-dev mailing list