All pastes #910857 Raw Edit

Something

public text v1 · immutable
·published 2008-02-20 07:31 UTC
rendered paste body
# 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
# Updated 2007-02-20 by Pixelz@EFnet


# 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]
	# 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
	foreach "- title players map game" [regexp -all -inline -expanded -- {
		<tr\sclass="search_result.+?		# find the part where the info is
		/GameServer/.+?/GameServer/.+?>(.+?)<.+?	# server name
		<tr\sclass="search_result.+?		# jump to the next part
		color=.+?(\d+?/\d+?)[^\d].+?			# players
		<a\shref="/MapSearch/.+?>(.+?)<.+?	# map name
		title="(.+?)"				# game name
  		} $data] {
		lappend matches [list $title $players $map $game]
	}
	# Shout the result
	if {![info exists matches]} {
		putmsg $chan "Did not find anything for $arg"
		return 1
	} else {
		foreach "title players map game" [lrange $matches 0 2] {
			putmsg $chan "\002Title\002: $title \002Map\002: $map \002Players\002 $players"
		}
		if {[llength $matches] > 3} {
			putmsg $chan "Found [expr "[llength $matches] - 3"] more match(es) but I'm not gonna show them to you :P"
		}
	}
}