Posted to tcl by kyak at Sun Oct 17 20:24:16 GMT 2021view raw
- package require tls
- set ::isconnected 0
- proc ircrecv {} {
- puts "ircrecv called"
- if {[eof $::irc]} {
- close $::irc
- }
- if {[gets $::irc line] >= 0} {
- puts $line
- }
- }
- proc ircsend {str} {
- puts "ircsend called"
- puts $::irc $str
- flush $::irc
- }
- proc ircloop {} {
- puts "ircloop called"
- if {!$::isconnected} {
- set ::irc [::tls::socket irc.oftc.net 6697]
- ::tls::handshake $::irc
- set ::isconnected 1
- fconfigure $::irc -blocking 0 -buffering line -translation auto -encoding utf-8
- fileevent $::irc readable ircrecv
- ircsend "NICK nick123765"
- ircsend "USER nick123765 0 * :user123765"
- }
- after 2000
- tailcall ircloop
- }
- after idle ircloop
- puts "going to event loop"
- vwait forever
Comments
Posted by mjanssen at Sun Oct 17 20:44:17 GMT 2021 [text] [code]
package require tls set ::isconnected 0 proc ircrecv {} { puts "ircrecv called" if {[eof $::irc]} { close $::irc } if {[gets $::irc line] >= 0} { puts $line } } proc ircsend {str} { puts "ircsend called" puts $::irc $str flush $::irc } proc ircloop {} { puts "ircloop called" if {!$::isconnected} { set ::irc [::tls::socket irc.oftc.net 6697] ::tls::handshake $::irc set ::isconnected 1 fconfigure $::irc -blocking 0 -buffering line -translation auto -encoding utf-8 fileevent $::irc readable ircrecv ircsend "NICK nick123765" ircsend "USER nick123765 0 * :user123765" } after 2000 ircloop } ircloop puts "going to event loop" vwait forever