Posted to tcl by kyak at Sun Oct 17 18:41:09 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. if {!$::isconnected} {
  24. set ::irc [::tls::socket irc.oftc.net 6697]
  25. ::tls::handshake $::irc
  26. set ::isconnected 1
  27. fconfigure $::irc -blocking 0 -buffering line -translation auto -encoding utf-8
  28. fileevent $::irc readable ircrecv
  29. ircsend "NICK nick123765"
  30. ircsend "USER nick123765 0 * :user123765"
  31. }
  32. after 2000
  33. tailcall ircloop
  34. }
  35.  
  36. ircloop
  37. vwait forever