#--------------------------------------------------------------------- # demo-connect.tcl # # Demo tcl for IRC bot eggdrop # # Upon a ".connect" on the partyline will make an outgoing # connection and hand over control to another procedure. # # v0: 13-Jan-2003 #--------------------------------------------------------------------- set connecthost www.egghelp.org set connectport 80 bind dcc m connect dcc:connect #--------------------------------------------------------------------- # proc dcc:connect makes and outgoing connection, sends the "HEAD" # request and hands over control to the receive procedure. #--------------------------------------------------------------------- proc dcc:connect { hand dccidx text } { global connecthost global connectport # make an outgoing connection # "conidx" will contain the idx of the outgoing connection set conidx [connect $connecthost $connectport] putlog "Connecting to $connecthost:$connectport ($conidx)." # send out the HEAD request to trigger a response by the server. set string {HEAD /index.htm HTTP/0.9} putdcc $conidx $string putdcc $conidx "" # hand over control to the receive procedure. control $conidx connect:rcv # log the command return 1 } #--------------------------------------------------------------------- # Upon a succesfull connection, all text sent by the server is # absorbed by the connect:rcv procedure. #--------------------------------------------------------------------- proc connect:rcv { idx text } { # if connection closed: control back to eggdrop if { $text == "" } { putlog "RCV: connection closed by server." return 1 } # putlog any text that eggdrop receives putlog "RCV: $text" # new text should come to this proc return 0 } putlog "Demo connect v0 loaded."