Posted to tcl by kyak at Sun Oct 17 20:24:16 GMT 2021view raw

  1. package require tls
  2.  
  3. set ::isconnected 0
  4.  
  5. proc ircrecv {} {
  6. puts "ircrecv called"
  7. if {[eof $::irc]} {
  8. close $::irc
  9. }
  10.  
  11. if {[gets $::irc line] >= 0} {
  12. puts $line
  13. }
  14. }
  15.  
  16. proc ircsend {str} {
  17. puts "ircsend called"
  18. puts $::irc $str
  19. flush $::irc
  20. }
  21.  
  22. proc ircloop {} {
  23. puts "ircloop called"
  24. if {!$::isconnected} {
  25. set ::irc [::tls::socket irc.oftc.net 6697]
  26. ::tls::handshake $::irc
  27. set ::isconnected 1
  28. fconfigure $::irc -blocking 0 -buffering line -translation auto -encoding utf-8
  29. fileevent $::irc readable ircrecv
  30. ircsend "NICK nick123765"
  31. ircsend "USER nick123765 0 * :user123765"
  32. }
  33. after 2000
  34. tailcall ircloop
  35. }
  36.  
  37. after idle ircloop
  38. puts "going to event loop"
  39. 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