[Tkabber-dev] r443 - branches/plugins-0.11.1/juick

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Nov 30 07:34:21 MSK 2010


Author: Totktonada
Date: 2010-11-30 07:34:21 +0300 (Tue, 30 Nov 2010)
New Revision: 443

Modified:
   branches/plugins-0.11.1/juick/juick.tcl
Log:
Juick, tkabber-0.11.1: add "S #dddddd+" command

Modified: branches/plugins-0.11.1/juick/juick.tcl
===================================================================
--- branches/plugins-0.11.1/juick/juick.tcl	2010-11-30 04:33:53 UTC (rev 442)
+++ branches/plugins-0.11.1/juick/juick.tcl	2010-11-30 04:34:21 UTC (rev 443)
@@ -11,10 +11,11 @@
 namespace eval juick {
 ::msgcat::mcload [file join [file dirname [info script]] msgs]
 
-hook::add draw_message_hook [namespace current]::ignore_server_messages 0
-hook::add draw_message_hook [namespace current]::handle_message 21
-hook::add chat_window_click_hook [namespace current]::insert_from_window
+hook::add draw_message_hook        [namespace current]::ignore_server_messages 0
+hook::add draw_message_hook        [namespace current]::handle_message 21
+hook::add chat_window_click_hook   [namespace current]::insert_from_window
 hook::add chat_win_popup_menu_hook [namespace current]::add_juick_things_menu 20
+hook::add chat_send_message_hook   [namespace current]::rewrite_send_juick_message 19
 
 hook::add draw_message_hook [namespace current]::update_juick_tab 8
 hook::remove draw_message_hook ::plugins::update_tab::update 8
@@ -103,19 +104,23 @@
     ::ifacetk::update_main_window_title
 }
 
-#proc rewrite_message \
-#     {vxlib vfrom vid vtype vis_subject vsubject \
-#      vbody verr vthread vpriority vx} {
-#    upvar 2 $vfrom from
-#    upvar 2 $vtype type
-#
-#    foreach xe $x {
-#        ::xmpp::xml::split $xe tag xmlns attrs cdata subels
-#
-#        switch -- $xmlns
-#        }
-#}
+proc rewrite_send_juick_message {chatid user body type} {
+    if {![is_juick $chatid] || ![cequal $type "chat"]} {
+        return
+    }
 
+    if {[regexp {^S (#\d+)\+\s*$} $body -> thing]} {
+        set xlib [chat::get_xlib $chatid]
+        set jid [chat::get_jid $chatid]
+
+        chat::add_message $chatid $user $type $body {}
+        message::send_msg $xlib $jid -type chat -body "S $thing"
+        message::send_msg $xlib $jid -type chat -body "$thing+"
+
+        return stop
+    }
+}
+
 proc insert_from_window {chatid w x y} {
     set thing ""
     set cw [chat::chat_win $chatid]



More information about the Tkabber-dev mailing list