I wrote/borrowed parts to this script that announces data to channels of posts reports so on and so forth from the forums, there is no real problem with that part. Where the issue lies is when the bot is rehashed or restarted it can't reopen the port because its already open.
So the part that is out of my depth is getting the script not to kill the bot just because it can't open the port again and either closing or just start listening again whichever better.
Here is all the relevant code to the script.
Code: Select all
# port for your script you want to listen on (you need to set same port in php script)
set botlisten(port) "16384"
set botlisten(ip) "127.0.0.1"
#Bot listen password. This currently isnt used its only listening to the localhost so no external siglnals can get to it. use only if hosting on a different server
set botlisten(password) ""
# channel you want to send output to
set botlisten(devchan) "#Admins"
set serverSocket [socket -server main -myaddr $botlisten(ip) $botlisten(port)]
proc main { sock host port } {
fconfigure $sock -buffering line
fileevent $sock readable [action $sock $host $port]
}
proc action { chan host port } {
global botlisten
if {![eof $chan]} {
set soc_data [gets $chan]
putlog $soc_data
if {$soc_data != ""} {
#This Relays what ever the bot is sending to the selected channel, this could also be a user
putquick "PRIVMSG $botlisten(devchan) :$soc_data"
putquick "$soc_data"
}
} {
close $chan
}
}
Thanks for the help, its always appreciated