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.

Ip location

Support & discussion of released scripts, and announcements of new releases.
Post Reply
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Ip location

Post by Madalin »

I saw that alot where looking for a still working ip location script as the old ones were outdated so here is my version.

Code: Select all

#### ++++ Author: MadaliN <madalinmen28@yahoo.com>
### +++ Website: www.Ascenture.ro
## +++ TCL Name: IP Location
# +++ Version: 1.0
## ++++
# Commands:
#	!ip 45.432.12.1
#
# IMPORTANT
#		- You need TDOM installed on your system
#		- You need to create an API key so that the script will work. For that visit http://ipinfodb.com/register.php
#
########
#	You need to be atleast VOICE or OP in the channel
########

bind PUBM - * ip:main

set temp(apikey) "179e8e059f0c9a5c519dc1021ef4aaadbefeb1316857066d1ad02e2baf959279"
set temp(trigger) {! . `}

package require http
package require tdom

proc ip:main {nick uhost hand chan arg} {
	global temp

	if {[string index $arg 0] in $temp(trigger)} {
		set temp(cmd) [string range $arg 1 end]
		set temp(cmd) [lindex [split $temp(cmd)] 0]
		set arg [join [lrange [split $arg] 1 end]]
	} elseif {[isbotnick [lindex [split $arg] 0]]} {
		set temp(cmd) [lindex [split $arg] 1]
		set arg [join [lrange [split $arg] 2 end]]
	} else { return 0 }

	if {[info commands command:$temp(cmd)] != ""} { command:$temp(cmd) $nick $uhost $hand $chan $arg }
}

proc command:ip {nick uhost hand chan arg} {
	global top temp

	if {[isvoice $nick $chan] || [isop $nick $chan]} {

		set ip [lindex [split $arg] 0]

		if {![regexp {^(?:(?:[01]?\d?\d|2[0-4]\d|25[0-5])(\.|$)){4}$} $ip]} { putserv "PRIVMSG $chan :\002$nick\002 -  NO/Invalid IP pattern. USAGE: !ip 193.193.193.193"; return }

		set token [http::config -useragent Mozilla]
		set token [http::geturl "http://api.ipinfodb.com/v2/ip_query.php?key=$temp(apikey)&ip=$ip"]
		set data [::http::data $token]
		::http::cleanup $token

		set XML $data

		set doc [dom parse $XML]
		set root [$doc documentElement]

		set code [$root selectNodes CountryCode]
		set code [$code asText]

		set country [$root selectNodes CountryName]
		set country [$country asText]

		set regionname [$root selectNodes RegionName]
		set regionname [$regionname asText]

		set city [$root selectNodes City]
		set city [$city asText]

		set latitude [$root selectNodes Latitude]
		set latitude [$latitude asText]

		set longitude [$root selectNodes Longitude]
		set longitude [$longitude asText]

		putserv "PRIVMSG $chan :\002$nick\002 - Informations about \00304$arg\003: Country Code - \00312$code\003, Country Name - \00312$country\003, Region Name - \00312$regionname\003, City - \00312$city\003 (Latitude \00303$latitude\003 Longitude \00303$longitude\003)"
	}
}

putlog "++ Succesfully loaded: \00312Ip Location"
H
Hero
Halfop
Posts: 49
Joined: Tue Jun 26, 2012 6:27 pm
Location: root@localhost
Contact:

Post by Hero »

Error!!

Code: Select all

[14:46:57] Tcl error [ip:main]: syntax error in expression "[string index $arg 0] in $temp(trigger)": extra tokens at end of expression
The Road To Hell Is Full Of Good Intentions
Post Reply