#--------------------------------------------------------------------- # menu.tcl # TCL script for IRC bot eggdrop # Demo tcl for opening a DCC connection and putting # it under [CONTROL] # Upon a public !menu, the bot attempts to establish a DCC connection # and connect the user to a menu. # v0: 18-Mar-2002 #--------------------------------------------------------------------- #--------------------------------------------------------------------- # set the port the bot will listen on #--------------------------------------------------------------------- set menuport 47000 #--------------------------------------------------------------------- # handle public !menu request: initialize DCC CHAT... #--------------------------------------------------------------------- bind pub o|- !menu pubmenu proc pubmenu { nick uhost hand chan text } { global menuport putlog "Request for menu by $nick (aka $hand)" putserv "PRIVMSG $nick :\001DCC CHAT chat [myip] $menuport\001" } #--------------------------------------------------------------------- # open listen port #--------------------------------------------------------------------- listen $menuport script presentmenu #--------------------------------------------------------------------- # menu through DCC #--------------------------------------------------------------------- proc presentmenu { idx } { # upon a successfull connection: # present the menu... menuchoice $idx # ... and control to waitchoice control $idx waitchoice } proc menuchoice { idx } { putdcc $idx "Make your choice (type a number or EXIT):" putdcc $idx "1. botnick" putdcc $idx "2. server:port" } #--------------------------------------------------------------------- # proc waitchoice is triggered if the user types something... # the proc returns either 0 or 1 # return 0: user input is sent to the procedure again # return 1: control is returned to the bot (will close connection) #--------------------------------------------------------------------- proc waitchoice { idx choice } { global botnick server switch -- $choice { 1 { putidx $idx "My nick is $botnick" } 2 { putdcc $idx "My server is $server"} EXIT { return 1 } "" { return 1 ; # connection terminated by client } default { putidx $idx "$choice is not possible, try again" } } # present the menu again... menuchoice $idx # ... and leave control here return 0 } putlog "Menu version 0 loaded: DCC connections on port $menuport."