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.

Game.tcl may need a quick fix

Help for those learning Tcl or writing their own scripts.
Post Reply
R
RoboCop
Voice
Posts: 13
Joined: Sun Aug 04, 2013 9:33 am

Game.tcl may need a quick fix

Post by RoboCop »

Hello I've been trying game.tcl for search GameServer IPs but it appears to give me a error saying "Tcl error [lookup]: invalid command name "putmsg" Is this command for older Eggdrop Versions below 1.6.21? Cos it doesn't seem to work well on that. Here is the TCL code script:

Code: Select all

# Script to get some extra information about the IP-Adress of your Counter-Strike Source server
# Script made by Mookie@Efnet Contact me for more information
# Suggestions are always welcome, post them on the forum on egghelp.org



# Settings

# Bind key? Default: !ip
set game(trigger) "!ip"

# Get-url timeout. Recommed to keep this as default
set game(timeout) "60000"
	

#########################################################
## Don't edit below unless you know what you're doing. ##
#########################################################

bind pub - $::game(trigger) lookup


proc lookup {nick uhost hand chan arg} {
	global game
	# Check if $arg exists
	if {![regexp -- {^(.+?):(.+?)$} $arg]} { putmsg $chan "Right format is: $::game(trigger) IP"; return }
	# Set formdata
	set formdata [http::formatQuery search $arg type server game cstrike2]
	# Going to url
	catch {set tok [http::geturl http://game-monitor.com/search.php?$formdata -timeout $::game(timeout)]} error
	if {[string match -nocase "*couldn't open socket*" $error]} {
			putlog "Error trying connect to url."
			return
	}
	# Went to url, setting data
	set data [http::data $tok]
	# Cleaning
	http::cleanup $tok
	# Regex time
	regexp -- {<b>Total Players/Max</b>(.+?)$} $data -> players
	if {![regexp -nocase {<a href="/GameServer/(.+?)">(.+?)</a></div></td></tr>} $data -> url title]} { putmsg $chan "Did not found anything for $arg"; return }
	regsub -all {<.*?>|&nbsp} $title {} title
	regexp -- {<td><a href="/MapSearch/cstrike2/.*?/">(.*?)</a>} $data -> map
	# Shout the result
	putmsg $chan "Title: $title Map: $map Players$players"
}
Another thing, game-monitor.com is not as popular as gametracker.com. Say if I wanted to convert game-monitor.com URL for gametracker.com what will the code have to be for it to work. Can you help please? I suck on TCL.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

putmsg is included in alltools.tcl

alltools.tcl is included with all versions of Eggdrop.

Make sure this line is included near the bottom of your conf file...

Code: Select all

source scripts/alltools.tcl
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
R
RoboCop
Voice
Posts: 13
Joined: Sun Aug 04, 2013 9:33 am

Post by RoboCop »

Alright I got alltools.tcl fixed thanks, only problem is that game-monitor.com query not giving me any results nor the bot will relay that IP query. I want to know how to resolve it or maybe use IP Gameserver query on gametracker.com
p
pizzahut
Voice
Posts: 1
Joined: Sun Nov 15, 2015 9:39 am

Post by pizzahut »

I came up with this, but seems it isn't working still:

[14:47:26] <pizzahut> !ip 87.98.237.191:27015
[14:47:27] <^lycosbot^> Did not found anything for 87.98.237.191:27015

Mind I have neither EggDrop nor TCL, so it was a shot in the dark.

I changed the form data to not only query CS:S servers, but all servers.

Code: Select all

	set formdata [http::formatQuery search $arg]
This should create an URL like this:

http://www.game-monitor.com/search.php? ... .191:27015

I changed the RegEx to match the current website layout.

Layout:

Code: Select all

<a href="/dmc_GameServer/87.98.237.191:27015/HLDS.pl_DMC_1.html">HLDS.pl DMC #1</a></div></td><td class="sp"><span>0 /</span><span>14</span> (4)</td><td>dmc_helix</td><td class="sip">
RegEx:

Code: Select all

	regexp -- {<td class="sp"><span>(.+?) /</span>} $data -> players
	if {![regexp -nocase {<a href="/.+?GameServer/.+?">(.+?)</a></div></td>} $data -> title]} { putmsg $chan "Did not found anything for $arg"; return }
	regsub -all {<.*?>|&nbsp} $title {} title
	regexp -- {<td>(.*?)</td><td class="sip">} $data -> map
Edited script:

Code: Select all

# Script to get some extra information about the IP-Adress of your Counter-Strike Source server
# Script made by Mookie@Efnet Contact me for more information
# Suggestions are always welcome, post them on the forum on egghelp.org



# Settings

# Bind key? Default: !ip
set game(trigger) "!ip"

# Get-url timeout. Recommed to keep this as default
set game(timeout) "60000"
	

#########################################################
## Don't edit below unless you know what you're doing. ##
#########################################################

bind pub - $::game(trigger) lookup


proc lookup {nick uhost hand chan arg} {
	global game
	# Check if $arg exists
	if {![regexp -- {^(.+?):(.+?)$} $arg]} { putmsg $chan "Right format is: $::game(trigger) IP"; return }
	# Set formdata
	set formdata [http::formatQuery search $arg]
	# Going to url
	catch {set tok [http::geturl http://game-monitor.com/search.php?$formdata -timeout $::game(timeout)]} error
	if {[string match -nocase "*couldn't open socket*" $error]} {
			putlog "Error trying connect to url."
			return
	}
	# Went to url, setting data
	set data [http::data $tok]
	# Cleaning
	http::cleanup $tok
	# Regex time
	regexp -- {<td class="sp"><span>(.+?) /</span>} $data -> players
	if {![regexp -nocase {<a href="/.+?GameServer/.+?">(.+?)</a></div></td>} $data -> title]} { putmsg $chan "Did not found anything for $arg"; return }
	regsub -all {<.*?>|&nbsp} $title {} title
	regexp -- {<td>(.*?)</td><td class="sip">} $data -> map
	# Shout the result
	putmsg $chan "Title: $title Map: $map Players$players"
}
I noticed that there should be a "www." in front of the domain, perhaps that's why it won't work. The response is a redirect if the "www." is omitted.
Post Reply