[Tkabber-dev] r336 - in trunk/plugins/bldjid: . msgs

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Apr 3 08:56:30 MSD 2010


Author: bigote
Date: 2010-04-03 08:56:30 +0400 (Sat, 03 Apr 2010)
New Revision: 336

Modified:
   trunk/plugins/bldjid/ChangeLog
   trunk/plugins/bldjid/bldjid.tcl
   trunk/plugins/bldjid/msgs/ru.msg
Log:
A small change in hash searching routine: -nocase is removed.
Fixed some bugs in "watch" code. Some new bugs introduced, probably.


Modified: trunk/plugins/bldjid/ChangeLog
===================================================================
--- trunk/plugins/bldjid/ChangeLog	2010-04-02 16:01:37 UTC (rev 335)
+++ trunk/plugins/bldjid/ChangeLog	2010-04-03 04:56:30 UTC (rev 336)
@@ -1,3 +1,20 @@
+2010-04-03  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
+
+--- Version 0.9.10.4 of the plugin.
+
+--- Files modified:
+    bldjid.tcl, ChangeLog, msgs/ru.msg.
+
+--- Changes:
+	A small change in hash searching routine: -nocase is removed.
+	Fixed some bugs in "watch" code. Some new bugs introduced, probably.
+
+---	TODO:
+	Most likely I'll drop "OR" mode. It's a bad idea to have a bunch
+	of nicks or jids to watch them separately. Each watch should consist
+	of only one item, and that item could have several elements:
+	one nick, one jid, one hash or one ver. That's all.
+
 2010-04-02  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
 
 --- Version 0.9.10.3 of the plugin.

Modified: trunk/plugins/bldjid/bldjid.tcl
===================================================================
--- trunk/plugins/bldjid/bldjid.tcl	2010-04-02 16:01:37 UTC (rev 335)
+++ trunk/plugins/bldjid/bldjid.tcl	2010-04-03 04:56:30 UTC (rev 336)
@@ -1,4 +1,4 @@
-# "Bldjid" plugin for Tkabber. 2010-04-02 v. 0.9.10.3
+# "Bldjid" plugin for Tkabber. 2010-04-03 v. 0.9.10.4
 # Written by Serge Yudin xmpp:bigote at jabber.ru
 # See README or README.ru file for usage.
 
@@ -251,10 +251,10 @@
 			}
 			if {[info exists watched_jids]} {
 				if {[info exists watched_jids(nick)]} {
-					set pattern [string map {\{ \\\{ \} \\\}} $nick]
-					set iam [whoami $xlib $group]
-					if {[string match -nocase *$pattern* $watched_jids(nick)] \
-					&&  ($iam == "admin" || $iam == "owner") \
+					set pattern $nick
+puts "pat: $pattern"
+puts "$watched_jids(nick)"
+					if {[string first $pattern [join $watched_jids(nick)]] >= 0 \
 					&& ![string match *%*@irc* $group]} {
 						[namespace current]::notify_jid $pattern $group $nick
 					}
@@ -262,17 +262,15 @@
 				if {[info exists watched_jids(jid)]} {
 					set pattern [string map {\{ \\\{ \} \\\}} $bare_jid]
 					set iam [whoami $xlib $group]
-					if {[string match -nocase *$pattern* $watched_jids(jid)] \
-					&&  ($iam == "admin" || $iam == "owner") \
+					if {[string first $pattern [join $watched_jids(jid)]] >= 0 \
+					&&  [string match *moderator* $iam] \
 					&& ![string match *%*@irc* $group]} {
 						[namespace current]::notify_jid $pattern $group $nick
 					}
 				}
 				if {[info exists watched_jids(hash)] && $ver_hash != ""} {
-					set pattern [string map {\{ \\\{ \} \\\}} $ver_hash]
-					set iam [whoami $xlib $group]
-					if {[string match *$pattern* $watched_jids(hash)] \
-					&&  ($iam == "admin" || $iam == "owner") \
+					set pattern [string map {\{ \\\{ \} \\\} \/ \\\/ \= \\\=} $ver_hash]
+					if {[string match *$pattern* [join $watched_jids(hash)]] \
 					&& ![string match *%*@irc* $group]} {
 						[namespace current]::notify_jid $pattern $group $nick
 					}
@@ -534,15 +532,28 @@
 					set key [lindex $jid 0]
 					if {$key == "ver" && [info exists watched_jids(ver)]} {
 						catch {unset watched_jids(ver)}
+						return stop
+					} elseif {$key == "nick" || $key == "jid" || $key == "hash"} {
+						set jid [lindex $jid 1]
 					} else {
-						set jid [lindex $jid 1]
+						set group [::chat::get_jid $chatid]
+						set cmd "/unwatch"
+						set msg [::msgcat::mc \
+						"Wrong syntax. Should be \"%s keyword parameter\".\
+						\nValid keywords are: nick, jid, hash, ver." $cmd]
+						::chat::add_message $chatid $group error $msg {}
+						return stop
 					}
 					if {$jid == "all"} {
 						catch {unset watched_jids($key)}
 					} elseif {[info exists watched_jids($key)]} {
 						for {set i 0} {$i < [llength $watched_jids($key)]} {incr i} {
-							if {[string match -nocase $jid [lindex $watched_jids($key) $i]]} {
+							if {[string equal $jid \
+							[join [lindex $watched_jids($key) $i]]]} {
 								set watched_jids($key) [lreplace $watched_jids($key) $i $i]
+								if {[llength $watched_jids($key)] == 0} {
+									catch {unset watched_jids($key)}
+								}
 								break
 							}
 						}
@@ -563,16 +574,18 @@
 
 proc bldjid::listwatch {chatid group} {
 	variable watched_jids
-	set header [::msgcat::mc "These are items you are watching:"]
+	set header [::msgcat::mc "These are items you are watching: "]
+	set msg ""
 	if {[info exists watched_jids]} {
 		foreach key {nick jid hash ver} {
 			if {[info exists watched_jids($key)]} {
 				lappend msg "\n$key: $watched_jids($key)"
 			}
 		}
-	} else {
-		set msg [::msgcat::mc "\nYour watchlist is empty."]
 	}
+	if {$msg == ""} {
+		set msg [::msgcat::mc "Your watchlist is empty."]
+	}
 	[namespace current]::print_search_res $chatid $group $header $msg
 }
 
@@ -809,7 +822,7 @@
 	if {[muc::is_compatible $where]} {
 		set chatid [::chat::chatid $xlib $where]
 		set jid $where/[get_our_groupchat_nick $chatid]
-		return [muc::get_affiliation $xlib $jid]
+		return [::muc::get_role $xlib $jid]/[muc::get_affiliation $xlib $jid]
 	}
 }
 
@@ -849,7 +862,7 @@
 			switch -- $which {
 				admin {
 					set iam [whoami $xlib $tmpgrp]
-					if {($iam == "admin" || $iam == "owner") \
+					if {[string match *moderator* $iam] \
 						&& ![string match *%*@irc* $tmpgrp]} {
 						if {$options(rooms2log) == ""} {
 							lappend grpjids $tmpgrp
@@ -939,7 +952,7 @@
 		} elseif {$options(matching_rules) == "exact"} {
 			if {$options(filter_admin_rooms)} {
 				set iam [whoami $xlib $room]
-				if {!($iam == "admin" || $iam == "owner")} {
+				if {![string match *moderator* $iam]} {
 					chat::add_message $chatid $group error $filter_turned_on {}
 					return stop
 				}
@@ -1017,7 +1030,7 @@
 			}
 			if {$options(filter_admin_rooms)} {
 				set iam [whoami $xlib $group]
-				if {!($iam == "admin" || $iam == "owner")} {
+				if {![string match *moderator* $iam]} {
 					chat::add_message $chatid $group error \
 					[::msgcat::mc "You turned off showing results in the rooms\
 					where you don't have admin privileges."] {}
@@ -1234,9 +1247,12 @@
 						set s_res [string equal $p_list($key) \
 						[lindex $item $key]]
 					} elseif {$key == 5} {
-						set s_res [string match $p_list($key) [lindex $item $key]]
+						set s_res [string match \
+						*[string map {\[ \\\[ \] \\\]} $p_list($key)]* \
+						[lindex $item $key]]
 					} else {
-						set s_res [string match -nocase *$p_list($key)* \
+						set s_res [string match -nocase \
+						*[string map {\[ \\\[ \] \\\]} $p_list($key)]* \
 						[lindex $item $key]]
 					}
 				} else {
@@ -1246,10 +1262,12 @@
 						[lindex $item $key]]]
 					} elseif {$key == 5} {
 						set s_res [expr $s_res & \
-						[string match *$p_list($key)* [lindex $item $key]]]
+						[string match \
+						*[string map {\[ \\\[ \] \\\]} $p_list($key)]* \
+						[lindex $item $key]]]
 					} else {
-						set s_res [expr $s_res & \
-						[string match -nocase *$p_list($key)* \
+						set s_res [expr $s_res & [string match -nocase \
+						*[string map {\[ \\\[ \] \\\]} $p_list($key)]* \
 						[lindex $item $key]]]
 					}
 				}
@@ -1340,7 +1358,7 @@
 	if {[winfo exists $w]} {
 		destroy $w
 	}
-	set msg [::msgcat::mc "Watched %s has entered the room %s as %s" $jid $room $nick]
+	set msg [::msgcat::mc "Watched %s\nhas entered the room %s\nas %s" $jid $room $nick]
     Dialog $w -title [::msgcat::mc "Entrance Notify"] \
         -modal none -separator 1 -anchor e -default 0 -parent .
         set f [$w getframe]
@@ -1474,7 +1492,7 @@
 		set xlib [::chat::get_xlib $chatid]
 		set iam [whoami $xlib $group]
 		if {[string match -nocase *$watched_jids(ver)* $pattern] \
-		&&  ($iam == "admin" || $iam == "owner") \
+		&&  [string match *moderator* $iam] \
 		&& ![string match *%*@irc* $group]} {
 			[namespace current]::notify_jid $pattern $group $nick
 		}
@@ -1499,7 +1517,7 @@
 			&&  ($ver_os == "Timeout" || $ver_os == "*NO VER/OS*")} {
 				set pattern [string map {\{ \\\{ \} \\\}} $ver_os]
 				if {[string match -nocase *$watched_jids(ver)* $pattern] \
-				&&  ($iam == "admin" || $iam == "owner") \
+				&&  [string match *moderator* $iam] \
 				&& ![string match *%*@irc* $group]} {
 					[namespace current]::notify_jid $pattern $group $nick
 				}

Modified: trunk/plugins/bldjid/msgs/ru.msg
===================================================================
--- trunk/plugins/bldjid/msgs/ru.msg	2010-04-02 16:01:37 UTC (rev 335)
+++ trunk/plugins/bldjid/msgs/ru.msg	2010-04-03 04:56:30 UTC (rev 336)
@@ -84,10 +84,10 @@
 "Тайм-аут для запроса версии (в секундах). Читайте описание опции в файле README.ru."
 ::msgcat::mcset ru "A list of conferences (full jids separated with spaces) that should be logged. If empty, all rooms will be logged." \
 "Список конференций (полные джиды, разделённые пробелами), логи которых вы хотите вести. Если поле пустое, будут вестись логи всех конференций."
-::msgcat::mcset ru "These are items you are watching:" "Вы наблюдаете за следующими элементами:"
-::msgcat::mcset ru "\nYour watchlist is empty." \
-"\nСписок наблюдения пуст."
-::msgcat::mcset ru "Watched %s has entered the room %s as %s" "Наблюдаемый %s вошёл в комнату %s под ником %s"
+::msgcat::mcset ru "These are items you are watching: " "Вы наблюдаете за следующими элементами: "
+::msgcat::mcset ru "Your watchlist is empty." \
+"Список наблюдения пуст."
+::msgcat::mcset ru "Watched %s\nhas entered the room %s\nas %s" "Наблюдаемый %s\nвошёл в комнату %s\nпод ником %s"
 ::msgcat::mcset ru "Entrance Notify" "Уведомление о входе пользователя"
 ::msgcat::mcset ru "Enable this option to log visitors' client version hash (see XEP-0115: Entity Capabilities for details)." \
 "Включите эту опцию, чтобы отслеживать хэш версии клиента (см. XEP-0115: Entity Capabilities для дополнительной информации)."



More information about the Tkabber-dev mailing list