This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

tcl request > functions too long for topic :-\

Old posts that have not been replied to for several years.
Locked
k
klasikahl

tcl request > functions too long for topic :-\

Post by klasikahl »

Here is what I would like this tcl to do.

1) Read from a file containing the data to be searched through
2) Send the matching item to an exterior program (quakestat in this case (quakestat=qstat))
3) Put the results from qstat into the channel along with a proceeding line of text
4) Allow adding to the file through public/msg commands (not really nessicary.)

To make this concept easier to grasp, I have created a little sample of what the data-holding-file would look like.

-File starts here-
FSK405 CTF 216.127.76.106:27960
-=BD=-'s NUT SHACK - CTF 65.113.115.247:27670
Enema Terror CTF 208.231.4.148:27960
-EOF-

Now, for example, if someone said ".q3 fsk" in my channel (publicly), I would want the script to *only* send 216.127.76.106:27960 (the corrosponding IP) to quakestat in "quakestat -q3s 216.127.76.106:27960". I do not need to have the script send IPs to quakestat with flags other than -q3s. Please keep in mind the *key* feature here is that it searches through the file, sends the IP to quakestat with -q3s flag, then returns the output of quakestat. Now there is a tcl out there which does send IPs to quakestat (or qstat, whichever you prefer) and prints the output into the channel it was requested by. However, it is in capable (AFAIK) of recivieving a string/sub-string of text which would (partially) match a server name, use the servers corrosponding IP and send it to qstat, and finally printing qstats output into the channel which requested it. Even though the explanation seems lengthy, overkill, and may make the tast seem impossible, from my 0 knowledge of tcl, I would think this could be done somewhat easily.

Thank you,

Zack
k
klasikahl

Post by klasikahl »

no one knows how to do something like this? :(
k
klasikahl

Post by klasikahl »

well i would like to revise my request. i have figured out how to get the bot to search and to send to qstat and return qstat's output, but i cant figure out how to get the bot to search and only return the substring which is the ip and port. any help=much appreciated. :)
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Try the regexp command. You can make a pattern to match the ip and port, then use regexp to extract them.
K
Kingster

Post by Kingster »

Or you can use the templates for QSTAT... A couple of the variables for server requests in QSTAT are $IPADDRESS and $PORT...

If you look in the original download for qstat, you'll find a servers.qstat and a players.qstat... Make qstat push the output through the template that you have chosen/edited/whatever, and voila, you get the IP and Port. I use something similar with qstat on Unreal Tournament - and the part of the template that I have is $IPADDRESS:$PORT, which will give an output of 216.127.76.106:27960

Hope that helps...
k
klasikahl

Post by klasikahl »

king, thats not it. what i need is for the script to extract the IP from a list of server names and their IPs, then have the script send the IP to qstat, then print out what qstat returns.
k
klasikahl

Post by klasikahl »

stdragon, where can i find docs on how to do this?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

The regexp part is pretty easy. Since the ip:port seems to be the last word on each line, use split and lindex to get that, then use

regexp "(.*):(.*)" $lastword match ip port

Then $ip will be the ip, $port will be the port.

To find the correct line, read in the file, and use string match or regexp to see if the line starts with what the user entered (e.g. if {[regexp $userinput $line]} { ... it matches ... }.

For the other stuff, like reading in the file, making a bind to listen for .q3, etc, you should be able to find that on your own. If you don't know tcl much, try www.tcl.tk and look in the Documentation section. There are tutorials too.
k
klasikahl

Post by klasikahl »

i actually know 0 tcl. thank you so much for the regexp line, i would have been lost without it. i will try tcl.tk for info on the split and lindex. :)
k
klasikahl

Post by klasikahl »

something is wacko with the tcl tutorials, as my connection is being refused on all attempts to resource.tcl.tk :evil: . also, i would like to revise the post where i wanted to revise the original post :P. as it turns out, i cant fiugre out how to send to qstat, or how to search a file. :(. im sorry for being so lame in my knowledge on tcl department. :oops:
k
klasikahl

Post by klasikahl »

also, i've been reading up on the forums, and i noticed that ppslim often times writes scripts for people. please please please ppslim, take a look at this and help me out. right now tcl is giving me a headache. so many baisics to learn before i can know how to do this script (i just took a brief glance at that tcl prog that teaches you interactively. got 8 lessons down, but i have school to worry about, too.)
Locked