Posted to tcl by kyak at Sun Oct 17 18:41:09 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 {} {
- 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
- }
- ircloop
- vwait forever