# Description: lets you set the incoming and outgoing character encoding package require roxirc 2.0 AddToPrefs inputencoding "cmd [namespace current]::checkencoding" [encoding system] AddToPrefs outputencoding "cmd [namespace current]::checkencoding" [encoding system] procs Send sendq proc checkencoding {window new} { global prefs if {$new == "\"\""} { upvar val val set val [encoding system] } elseif {[catch {encoding convertto $new "this is a test string"} err]} { Echo $window "\[ error \] Cannot set encoding: $err" return -code return } } proc sendq {} { global prefs sendq flood irc ignore if {[llength $sendq] > 0} { set line [lindex $sendq 0] #puts "Out: $line" if {[info exists irc]} { fconfigure $irc -encoding $prefs(outputencoding) if {[catch {puts $irc $line} err] && ![info exists connecting]} { Echo .0 "\[ error \] Error sending to server: [geterror $err]" error default set sendq {} } fconfigure $irc -encoding $prefs(inputencoding) } else { Echo all "\[ server \] You are not connected to a server" server default set sendq {} } set sendq [lreplace $sendq 0 0] after $prefs(flooddelay) sendq } else { unset flood sendq Echo .0 "\[ info \] Flood protection deactivated" info default } } proc Send {line} { global irc connecting info sendq flood info prefs ignore if {[info exists flood]} { if {[llength $sendq] < $prefs(floodmaxq)} {lappend sendq $line} return } if {[expr [clock clicks -milliseconds] - $info(send,last)] < $prefs(floodtime)} { incr info(send,num) } else { set info(send,last) [clock clicks -milliseconds] set info(send,num) 0 } if {$info(send,num) >= $prefs(floodlines) && $prefs(flood)} { set flood 1 set sendq {} Echo .0 {[ info ] Flood protection activated} info default Send $line sendq return } #puts "Out: $line" fconfigure $irc -encoding $prefs(outputencoding) if {[info exists irc]} { if {[catch {puts $irc $line} err]} { Echo .0 "\[ error \] Error sending to server: [geterror $err]" error default } } elseif {[info level] > 1 && [string equal [upvar #1 fh fh] ""] && [info exists fh] && $fh != ""} { catch {puts [lindex [lindex $tmp $s] 2] $line} } else { set tmp "" foreach x [file channels sock*] { if {![catch {fileevent $x readable} out]} {lappend tmp $out} } if {[llength [set s [lsearch -glob -all $tmp "Connected *"]]] == 1} { catch {puts [lindex [lindex $tmp $s] 2] $line} } elseif {![info exists connecting]} { Echo all {[ server ] You are not connected to a server} server default } } fconfigure $irc -encoding $prefs(inputencoding) } proc unload {} { RemoveFromPrefs inputencoding RemoveFromPrefs outputencoding }