ok, so I kind of got this working thus far:
dxclusterbot.tcl
Code:
# dxcluster_bot
# ver 0.1
# kc2ugv 28 MAR 10
# licensed under the GPL vr 2 or later
# to connect to the cluster, issue a .cluster_connect
#
# to disconnect from the cluster, issue a .cluster_disconnect
#
set vDxClusterBotVersion 1.0
listen 12345 script IncomingConnection
proc IncomingConnection {idx} {
#We've got a new incoming connection, hand it over to our "handler"
control $idx IncomingTransmission
}
proc IncomingTransmission {idx text} {
#Did we recieve a new line, or did the remote end close the connection?
if {$text != ""} {
#Slit the text into a list and retrieve the command..
set data [split $text]
set command "write"
#.. and see what we're supposed to do.
#Hint: this would be a nice place to add a command for authentication...
switch $command {
write {
#Use list-element 1 as channel, and the rest as the message to be sent
#Considder adding a check whether the connection has authenticated or not yet.
#Atleast we do check that it's a valid channel..
if {[validchan [set chan "#testingdxcluster"]]} {
puthelp "PRIVMSG $chan :[join $text]"
}
}
}
} else {
#remote connection closed, do some cleanup here if needed
#Hint: here you would un-authenticate the idx (connection identifier)
#For now tho, we'll just do a putlog for fun
putlog "Remote connection $idx dropped"
}
}
But, I had to hack it with Expect:
Code:
#!/usr/bin/expect -f
spawn telnet dxc.ab5k.net
expect "Please enter your call: "
send "kc2ugv\r"
interact
And then this script, to put it all together:
Code:
#!/bin/bash
~/egg/eggdrop clusterbot.conf
~/egg/dxcluster_login.exp | nc localhost 12345
Not pretty, but functional. It does what it's supposed to do. I know I can get that expect stuff into the tcl script somehow.