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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Mon Mar 23 05:15:36 MSK 2009


Author: bigote
Date: 2009-03-23 05:15:35 +0300 (Mon, 23 Mar 2009)
New Revision: 179

Modified:
   trunk/plugins/bldjid/ChangeLog
   trunk/plugins/bldjid/README
   trunk/plugins/bldjid/bldjid.tcl
Log:
New command added: /bldhelp
Shows short usage help for this plugin.


Modified: trunk/plugins/bldjid/ChangeLog
===================================================================
--- trunk/plugins/bldjid/ChangeLog	2009-03-17 03:06:29 UTC (rev 178)
+++ trunk/plugins/bldjid/ChangeLog	2009-03-23 02:15:35 UTC (rev 179)
@@ -1,3 +1,18 @@
+2009-03-23  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
+
+---	Version 0.4a1 of the plugin.
+---	Files modified:
+	bldjid.tcl, README, ChangeLog.
+
+--- Changes:
+	New command added: /bldhelp
+	Shows short usage examples of plugin commands.
+
+	New procedure added that allows to gather nicks and JIDs
+	without having to patch muc.tcl 
+	It's not working yet, will be adapted to plugin's necessities.
+	Thanks to sceptic <mailto:alexey.smirnov at gmx.com>
+
 2009-03-17  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
 
 --- Version 0.4a of the plugin.

Modified: trunk/plugins/bldjid/README
===================================================================
--- trunk/plugins/bldjid/README	2009-03-17 03:06:29 UTC (rev 178)
+++ trunk/plugins/bldjid/README	2009-03-23 02:15:35 UTC (rev 179)
@@ -5,9 +5,12 @@
 Let them waste as least of your time as possible!
 
 Usage:
+---	To show short usage help of the plugin's commands:
+/bldhelp
+
 ---	To ban in all rooms where you have admin privileges:
 /bldjid JID
-Some reason for banning.
+Some reason for banning (optional).
 
 ---	To unban a banned person in these rooms:
 /unbldjid JID
@@ -19,7 +22,7 @@
 
 ---	Usage:
 /banjid JID
-Some reason for banning.
+Some reason for banning (optional).
 
 ---	If you're in a good mood (it's your birthday, for instance),
 you might want to unban all people banned in a certain room.

Modified: trunk/plugins/bldjid/bldjid.tcl
===================================================================
--- trunk/plugins/bldjid/bldjid.tcl	2009-03-17 03:06:29 UTC (rev 178)
+++ trunk/plugins/bldjid/bldjid.tcl	2009-03-23 02:15:35 UTC (rev 179)
@@ -1,4 +1,4 @@
-# "Bldjid" plugin for Tkabber. 2009-03-15 v. 0.4a
+# "Bldjid" plugin for Tkabber. 2009-03-23 v. 0.4a1
 # Written by Serge Yudin xmpp:bigote at jabber.ru
 # See README file for usage.
 
@@ -6,6 +6,8 @@
 namespace eval bldjid {
 	variable hid_grp_msg
 	variable list_to_show
+	variable jids_by_chats [dict create]
+
 	set winid 0
     ::msgcat::mcload [file join [file dirname [info script]] msgs]
 
@@ -15,12 +17,60 @@
         [namespace current]::handle_commands 17
 }
 
+## REQUIRED TCL/TK 8.5 and above ##
+## Thanks to sceptic <alexey.smirnov at gmx.com>
+## Adapted to bldjid's necessities by Serge Yudin
+proc bldjid::smart_enter_exit_message {xlib jid type x args} {
+    variable jids_by_chats
+
+    if {$type != "available"} {
+        return
+    }
+
+    set group [::xmpp::jid::stripResource $jid]
+    set chatid [::chat::chatid $xlib $group]
+
+    if {[::chat::is_opened $chatid]} {
+
+        if {[::chat::is_groupchat $chatid]} {
+                                                                                                        
+            if {[::xmpp::jid::resource $jid] == ""} {
+                return
+            }
+
+            set nick [::chat::get_nick $xlib $jid groupchat]
+            set real_jid [::muc::get_real_jid $xlib $group/$nick]
+
+            if {$real_jid == ""} {
+                return
+            }
+
+            if {[dict exists $jids_by_chats $group]} {
+                set jids [dict get $jids_by_chats $group]
+
+                if {[lsearch -exact $jids $real_jid] >= 0} {
+                    return
+                }
+            }
+
+            dict lappend jids_by_chats $group $real_jid
+
+            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
+
 proc bldjid::command_comps {chatid compsvar wordstart line} {
     upvar 0 $compsvar comps
 
     if {!$wordstart} {
         lappend comps {/bldjid } {/unbldjid } {/banjid } {/amnesty } \
-		{/visitors } {/visited } {/pickup }
+		{/visitors } {/visited } {/pickup } {/bldhelp }
     }
 }
 
@@ -40,6 +90,8 @@
         set cmd /visited
 	} elseif {[string match {/pickup*} $body]} {
         set cmd /pickup
+	} elseif {[string match {/bldhelp*} $body]} {
+	    set cmd /bldhelp
     } else return
 
     if {$type != "groupchat"} return
@@ -81,6 +133,7 @@
         }
 	} elseif {[string equal [string range $body 0 7] "/pickup "]} {
 		set index [muc::parse_nick $body 8]
+	} elseif {[string equal [string range $body 0 7] "/bldhelp"]} {
 	} else {
     	return
     }
@@ -197,6 +250,34 @@
 			\n[lindex $list_to_show $index]" {}
 		}
 		}
+
+		/bldhelp {
+		set group [chat::get_jid $chatid]
+		chat::add_message $chatid $group error "Short usage examples for Bldjid plugin" {}
+		chat::add_message $chatid $group info "Ban in all rooms where you have admin privileges:\
+			\n/bldjid JID\
+			\nSome reason for banning (optional)." {}
+		chat::add_message $chatid $group info "Unban a banned person in these rooms:\
+			\n/unbldjid JID" {}
+		chat::add_message $chatid $group info "Ban a user in the current room by his/her JID:\
+			\n/banjid JID\
+			\nSome reason for banning (optional)." {}
+		chat::add_message $chatid $group info "Unban all people banned in the current room:\
+			\n/amnesty" {}
+		chat::add_message $chatid $group info "Show all visitors of the current room:\
+			\n/visitors" {}
+		chat::add_message $chatid $group info "Show all visitors of rooms that match *room*:\
+			\n/visitors room" {}
+		chat::add_message $chatid $group info "Show all visits to all rooms:\
+			\n/visited" {}
+		chat::add_message $chatid $group info "Show visits made by someone whose nick or JID matches *nick*:\
+			\n/visited nick" {}
+		chat::add_message $chatid $group info "Shows visits made by *nick*, to the rooms that match *room*:\
+			\n/visited nick\
+			\nroom" {}
+		chat::add_message $chatid $group info "Choose a JID from the list given by /visit* commands:\
+			\n/pickup ?n?" {}
+		}
 	}
     return stop
 }
@@ -310,3 +391,6 @@
 		list $muc::users(role,$xlib,$jid) $muc::users(affiliation,$xlib,$jid)
 	}
 }
+
+
+



More information about the Tkabber-dev mailing list