[wrapper::getfirstchildwithxmlns $xmldata http://jabber.org/protocol/chatstates]]
set receipt [wrapper::getchildswithtagandxmlns $xmldata request urn:xmpp:receipts]
+ set time [clock seconds]
+ set delay [lindex [wrapper::getchildswithtag $xmldata delay] 0]
+ if {$delay ne {}} {
+ set stamp [wrapper::getattribute $delay stamp]
+ if {[catch {set time [clock scan $stamp -format {%Y-%m-%dT%H:%M:%S%Z}]} err]} {
+ Log $ctx "Delayed delivery error \"$stamp\": $err"
+ }
+ }
+
foreach x [wrapper::getchildswithtag $xmldata x] {
switch -exact -- [wrapper::getattribute $x xmlns] {
"jabber:x:delay" {}
set newnick [lindex [split $msg] 4]
}
}
- Callback $ctx traffic $what $fromjid $fromres $newnick -group irc
+ Callback $ctx traffic $what $fromjid $fromres \
+ $newnick $time -group irc
return 0
} elseif {[regexp {^\* (\S+) (.*)$} $msg -> fromres msg]} {
set what action
set msg [string range $msg 3 end]
}
if {[string length $msg] > 0} {
- Callback $ctx chat $fromjid $fromres $msg $what
+ Callback $ctx chat $fromjid $fromres $msg $what $time
}
}
chat {
if {[llength $body] > 0} {
Callback $ctx chat $a(from) $nick \
- [wrapper::getcdata [lindex $body 0]] normal
+ [wrapper::getcdata [lindex $body 0]] normal $time
}
}
normal {
if {[llength $nicktag] >0} {
set from "[wrapper::getcdata [lindex $nicktag 0]] <$from>"
}
- set time [clock seconds]
- set delay [lindex [wrapper::getchildswithtag $xmldata delay] 0]
- if {$delay ne {}} {
- set stamp [wrapper::getattribute $delay stamp]
- catch {set time [clock scan $da(stamp) \
- -format {%Y-%m-%dT%H:%M:%S%Z}]}
- }
set p [list -date $time -subject $subject]
if {$thread ne {}} {lappend p -thread $thread}
lappend p -body [set bodydata [wrapper::getcdata [lindex $body 0]]]
}
headline {
Callback $ctx chat $a(to) $a(from) \
- "header: [wrapper::etcdata [lindex $body 0]]" normal
+ "header: [wrapper::etcdata [lindex $body 0]]" normal $time
Log $ctx "$a(from)->$a(to) headline $xmldata"
}
error {
return
}
-proc ::xmppplugin::SendReceipt {Chat} {
- lappend xlist [wrapper::createtag received \
- -attrlist {xmlns urn:xmpp:receipts}]
- set margs [list -type $chat(type) -xlist $xlist]
- if {![catch {set thread [dict get $xmpp(opts) $chat(channel) -thread]}]} {
- lappend margs -thread $thread
- }
- eval [linsert $margs 0 $xmpp(jlib) send_message $chat(channel)]
-}
-
package provide xmppplugin $::xmppplugin::version
# -------------------------------------------------------------------------
}
close {
foreach {target} $args break
- Debug $Session [mc "closing $s" $target]
+ Debug $Session [mc "closing %s" $target]
XmppRemoveWindow $Session $target
}
addchat {
}
}
chat {
- foreach {target nick msg type} $args break
+ foreach {target nick msg type time} $args break
if {$type eq ""} {set type normal}
+ if {$time eq ""} {set time [clock seconds]}
set w [XmppCreateWindow $Session $target -type chat]
XmppAlert $Session $target
switch -exact -- [winfo class $w] {
- Chatwidget {$w message $msg -nick $nick -type $type}
+ Chatwidget {$w message $msg -nick $nick -type $type -time $time}
Messagewidget {
- $w add -from $nick -to Me -body $msg -date [clock seconds]
+ $w add -from $nick -to Me -body $msg -date $time
}
default {puts stderr "invalid chat target \"$target\""}
}
}
}
traffic {
- foreach {action target nick new} $args break
+ foreach {action target nick new time} $args break
+ if {$time eq ""} {set time [clock seconds]}
set w [XmppFindWindow $Session $target]
if {[winfo class $w] ne "Chatwidget"} {return}
switch -exact -- $action {
joining { XmppCreateWindow $Session $target -type groupchat}
entered {
eval [linsert $args 0 $w name add $nick]
- $w message [mc "%s entered" $nick] -nick $nick -type system
+ $w message [mc "%s entered" $nick] -nick $nick -time $time -type system
}
left {
$w name delete $nick
- $w message [mc "%s left" $nick] -nick $nick -type system
+ $w message [mc "%s left" $nick] -nick $nick -time $time -type system
}
nickchange {
$w name delete $nick
eval [linsert $args 0 $w name add $new]
$w message [mc "%s is now known as %s" $nick $new] \
- -nick $nick -type system
+ -nick $nick -time $time -type system
}
default {
- $w message "$nick $action" -nick $nick -type system
+ $w message "$nick $action" -nick $nick -time $time -type system
}
}
}