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 {<.*?>| } $title {} title
regexp -- {<td><a href="/MapSearch/cstrike2/.*?/">(.*?)</a>} $data -> map
# Shout the result
putmsg $chan "Title: $title Map: $map Players$players"
}