I would be very grateful if someone could point me in the right direction with something I'm a bit stuck on.
I'll admit I'm a beginner TCL programmer, but have coded in various other languages before.
Basically I have a TCL script that works fine if I run it outside of Eggdrop, however when loading it in Eggdrop I'm hitting some issues.
What my script does is connect to a TCP port on a gameserver, login and monitor chat taking place on the server. It then simply prints any chat messages it finds.
I believe the problem to be because I'm using "vwait eventLoop". This causes the bot to hang while loading, and I'm a bit unsure of how I should rewrite this to be eggrop friendly.
My script is below and I would be very grateful for any help I can get in getting this to work with eggdrop.
Thanks!!
Code: Select all
# Set server connection details
set gsname "xxxx"
set gsip "xxxx"
set gsadmport xxxx
set gspass "xxxx"
set gsnick "xxx"
# Handle output from the server and print chat messages to channel
proc read_sock {sock} {
set l [gets $sock]
if {[string match *Chat* $l]} {
puthelp "PRIVMSG #gsadmins :Server #02 - $l"
}
}
# Setup the connection
set gsSock [socket $gsip $gsadmport]
# Monitor the socket
fileevent $gsSock readable [list read_sock $gsSock]
# Line buffer the socket
fconfigure $gsSock -buffering line
# Send admin password
puts $gsSock "$gspass"
# Identify us!
puts $gsSock "/nick $gsnick"
# Wait and handle events
vwait eventLoop