TclApps Library Source Code
Check-in [b19a3a2f4e]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed string/list confusion in the message parsing that mishandled nick changes from irc.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b19a3a2f4e8514556f1efca5e9288f3e49ed09c4
User & Date: patthoyts 2009-05-25 16:02:26.000
Context
2009-06-02
11:41
* tkchat.tcl (::tkchat::Progress): Improved progress bar handling. This hopefully fixes the occasional spinning of the progress bar when the associated action has long finished. check-in: 5b5ef6bf79 user: rmax tags: trunk
2009-05-25
16:02
Fixed string/list confusion in the message parsing that mishandled nick changes from irc. check-in: b19a3a2f4e user: patthoyts tags: trunk
2009-05-24
23:21
Tidied up feature discovery and xep0115 caps support and ensure we handle conversation threads for chat sessions. check-in: e8d6f2343f user: patthoyts tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to apps/tkchat/ChangeLog.





1
2
3
4
5
6
7





2009-05-25  Pat Thoyts  <[email protected]>

	* tkchat.tcl: Tidied up feature discovery and xep0115 caps support
	and ensure we handle conversation threads for chat sessions.

2009-05-24  Pat Thoyts  <[email protected]>

>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2009-05-25  Pat Thoyts  <[email protected]>

	* tkchat.tcl: Fixed string/list confusion in the message parsing
	that mishandled nick changes from irc.

2009-05-25  Pat Thoyts  <[email protected]>

	* tkchat.tcl: Tidied up feature discovery and xep0115 caps support
	and ensure we handle conversation threads for chat sessions.

2009-05-24  Pat Thoyts  <[email protected]>

Changes to apps/tkchat/tkchat.tcl.
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
    }
}

namespace eval ::tkchat {
    variable chatWindowTitle "The Tcler's Chat"

    variable HEADUrl {http://tcllib.cvs.sourceforge.net/*checkout*/tcllib/tclapps/apps/tkchat/tkchat.tcl?revision=HEAD}
    variable rcsid   {$Id: tkchat.tcl,v 1.469 2009/05/24 23:21:24 patthoyts Exp $}

    variable MSGS
    set MSGS(entered) [list \
	    "%user% has entered the chat!" \
	    "Out of a cloud of smoke, %user% appears!" \
	    "%user% saunters in." \
	    "%user% wanders in." \







|







275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
    }
}

namespace eval ::tkchat {
    variable chatWindowTitle "The Tcler's Chat"

    variable HEADUrl {http://tcllib.cvs.sourceforge.net/*checkout*/tcllib/tclapps/apps/tkchat/tkchat.tcl?revision=HEAD}
    variable rcsid   {$Id: tkchat.tcl,v 1.470 2009/05/25 16:02:26 patthoyts Exp $}

    variable MSGS
    set MSGS(entered) [list \
	    "%user% has entered the chat!" \
	    "Out of a cloud of smoke, %user% appears!" \
	    "%user% saunters in." \
	    "%user% wanders in." \
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335

8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
	    ::tkchat::addSystem .txt "|| MsgCB > type=$type, args=$args"
	}
    }
}

proc ::tkjabber::parseMsg { nick msg color mark timestamp } {
    global Options
    set msg [split $msg " "]
    set opts {}
    if { [lsearch -exact $Options(BridgeNames) $nick] != -1} {
	set nick [lindex $msg 0]
	set msg [lrange $msg 1 end]
	if { $nick eq "***" } {
	    set nick [lindex $msg 0]
	    set action [lrange $msg 1 end]
	    if { $action eq "leaves" || $action eq "joins" } {
		set action [string map { joins entered leaves left } $action]
		lappend action IRC
	    } elseif { [lrange $action 0 end-1] eq "is now known as" } {
		lappend nick [lindex $action end]
		set action [list nickchange IRC]
	    } else {
		::log::log notice "Unknown IRC command '$msg'"
		return
	    }
	    ::tkchat::addTraffic .txt $nick $action $mark $timestamp
	    return
	} elseif { $nick eq "*" } {
	    set nick [lindex $msg 0]
	    set action [lrange $msg 1 end]
	    if { $action eq "entered" || $action eq "left" } {
		lappend action WebChat
		::tkchat::addTraffic .txt $nick $action $mark $timestamp
		return
	    } else {
		set msg [linsert $action 0 /me]
	    }
	}
    } elseif { $nick eq $::Options(JabberConference) } {
	::tkchat::addSystem .txt $msg
	return
    }
    if { [lindex $msg 0] eq "/nolog" } {
	set msg [lrange $msg 1 end]
	lappend opts nolog 1
    } elseif { [uplevel 1 { info exists tkchatAttr(nolog) }] \
	    && [uplevel 1 { set tkchatAttr(nolog) }] } {
	lappend opts nolog 1
    }
    if { $nick eq "" } {

	if { [lrange $msg 1 3] eq "has become available" } {
	    ::tkchat::addTraffic .txt [lindex $msg 0] entered $mark $timestamp
	} elseif { [string match "has left*" [lrange $msg 1 2]] } {
	    ::tkchat::addTraffic .txt [lindex $msg 0] left $mark $timestamp
	} elseif { [string match "is now known as" [lrange $msg 1 4]] } {
	    set nick [list [lindex $msg 0] [lindex $msg end]]
	    ::tkchat::addTraffic .txt $nick nickchange $mark $timestamp
	}
    } else {
	if { [lindex $msg 0] eq "/me" } {
	    set msg [join [lrange $msg 1 end]]
	    set msgtype ACTION
	} else {
	    set msg [join $msg]
	    set msgtype NORMAL
	}
	::tkchat::addMessage \
		.txt $color $nick $msg $msgtype $mark $timestamp $opts
    }
}








<


|
<

<
|

|
|
|
|








<
|





|






|
|





|
>
|
|
|
|
|
|



|
|


<







8286
8287
8288
8289
8290
8291
8292

8293
8294
8295

8296

8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310

8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345

8346
8347
8348
8349
8350
8351
8352
	    ::tkchat::addSystem .txt "|| MsgCB > type=$type, args=$args"
	}
    }
}

proc ::tkjabber::parseMsg { nick msg color mark timestamp } {
    global Options

    set opts {}
    if { [lsearch -exact $Options(BridgeNames) $nick] != -1} {
        regexp {^([^\s]+)\s(.*)} $msg -> nick msg

	if { $nick eq "***" } {

            regexp {^([^\s]+)\s(.*)} $msg -> nick action
	    if { $action eq "leaves" || $action eq "joins" } {
		set action [list \
                    [string map {joins entered leaves left} $action] IRC]
	    } elseif {[string match "is now known as*" $action]} {
                set nick [list $nick [string range $action 16 end]]
		set action [list nickchange IRC]
	    } else {
		::log::log notice "Unknown IRC command '$msg'"
		return
	    }
	    ::tkchat::addTraffic .txt $nick $action $mark $timestamp
	    return
	} elseif { $nick eq "*" } {

            regexp {^([^\s]+)\s(.*)} $msg -> nick action
	    if { $action eq "entered" || $action eq "left" } {
		lappend action WebChat
		::tkchat::addTraffic .txt $nick $action $mark $timestamp
		return
	    } else {
		set msg "/me $action"
	    }
	}
    } elseif { $nick eq $::Options(JabberConference) } {
	::tkchat::addSystem .txt $msg
	return
    }
    if {[string match "/nolog *" $msg]} {
	set msg [string range $msg 7 end]
	lappend opts nolog 1
    } elseif { [uplevel 1 { info exists tkchatAttr(nolog) }] \
	    && [uplevel 1 { set tkchatAttr(nolog) }] } {
	lappend opts nolog 1
    }
    if {$nick eq ""} {
        regexp {^([^\s]+)\s(.*)} $msg -> nick action
	if {[string match "has become available*" $action]} {
	    ::tkchat::addTraffic .txt $nick entered $mark $timestamp
	} elseif {[string match "has left*" $action]} {
	    ::tkchat::addTraffic .txt $nick left $mark $timestamp
	} elseif {[string match "is now known as *" $action]} {
            set nick [list $nick [string range $action 16 end]]
	    ::tkchat::addTraffic .txt $nick nickchange $mark $timestamp
	}
    } else {
	if {[string match "/me *" $msg]} {
	    set msg [string range $msg 4 end]
	    set msgtype ACTION
	} else {

	    set msgtype NORMAL
	}
	::tkchat::addMessage \
		.txt $color $nick $msg $msgtype $mark $timestamp $opts
    }
}