| View previous topic :: View next topic |
| Author |
Message |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Wed Jun 12, 2013 9:15 am Post subject: Ip location |
|
|
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: |
#### ++++ 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"
|
_________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
Hero Halfop
Joined: 26 Jun 2012 Posts: 49 Location: root@localhost
|
Posted: Sat Jun 22, 2013 5:47 am Post subject: |
|
|
Error!!
| Code: | | [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 |
|
| Back to top |
|
 |
|