Simple Tcl example bot

By mentalglitch on May 14, 2008

Tcl example bot (use in linux OS but will work on windows) it doesnt do anything aside from connect identify to nickserv and join the channels specified

if you want to add to this such as commands and admin authorization contact me here on hawkee.com via msg

run with: 'tclsh filename.tcl &'
if you don't add the & at the end, your terminal window will be locked until the bot is closed.

do what you like with the code =D

#### "Simple Tcl irc bot", Version: 1.0, Created by: mentalglitch

package require Tcl 8.5

### Vairables. Edit these

array set main {
 server "irc.icq.com"
 port "6667"
 nick "T-Bot"
 user "TclBot"
 rname "Simple Tcl irc bot"
 nickpass "qj3h5bag"
 mymodes "+iBT-G"
 channels "#chan1,#chan2,#chan3"
}

### Do not edit below this line

set main(sock) "0"

### Procs

proc send {raw} {
 global main
 puts $main(sock) "$raw"; flush $main(sock)
 return
}

proc startsock {s p} {
 global main
 catch {socket $s $p} main(sock)
 send "NICK $main(nick)"
 send "\nUSER $main(user) * $main(server) :$main(rname)"
 recv $main(sock)
}

proc recv {sid} {
 global main
 while {[set argu [gets $sid]] != "-1"} {
  if {[llength [split $argu]] < 1} {break}
  set argu [split $argu]
  set nick [lindex [split [lindex $argu 0] :!@] 1]
  set user [lindex [split [lindex $argu 0] :!@] 2]
  set host [lindex [split [lindex $argu 0] :!@] 3]
  set sw "[lindex $argu 1]"
  switch -exact $sw {
   001 {serverinit $sid}
   PING {send "PONG [join [lindex $argu 2]]"}
  }
 }
}

proc serverinit {sid} {
 global main
 send "MODE $main(nick) $main(mymodes)"
 send "PRIVMSG nickserv :identify $main(nickpass)"
 after 420 set next 1
 vwait next
 send "JOIN :$main(channels)"
}
startsock $main(server) $main(port)

Comments

Sign in to comment.
juhapuha   -  Nov 24, 2008

I've made a TCL bot too. The base takes hours to be completed, if you want your bot so be smart (know it's channels, channels of user, hosts, prefixes, authnames etc...) though the biggest problem for me was getting the new prefixes of nicks when they got mass-deopped/opped/voiced/devoiced.. Spending time with the bot makes it smar, light and efficient.

 Respond  
mentalglitch   -  Jun 17, 2008

don\'t use this due to various TCL updates it wont work anymore

 Respond  
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.