TCL IRC bot

By supafreky on Jan 24, 2009

Connects to an IRC server you specify and idles. Basically this is a frame for an IRC bot.

Command line arguments:
tclsh client.tcl irc.kingskrown.com 6667

if {$argc <= 1} {
   puts "Usage: client <dstaddr> <dstport>"
   return
}

set dstaddr [lindex $argv 0]
set dstport [lindex $argv 1]
set nick "tcl"
set ident "svs"
set gecos "tcl"

set fd [socket $dstaddr $dstport]

puts $fd "NICK $nick"
flush $fd
puts $fd "USER $ident \"\" \"\" :$gecos"
flush $fd

while {[set in [gets $fd]] != -1} {
   if {[regexp -nocase {^PING (:[^ ]+)$} $in regex match]} {
      puts $fd "PONG $match"
      flush $fd
   }
   puts stdout $in
}

close $fd

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.