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.