#
# TCL scripts by Ofloo all rights reserved.
#
# HomePage: http://ofloo.net/
# CVS: http://cvs.ofloo.net/
# Email: support[at]ofloo.net
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# Requires lib ip2c
# svn co https://narf.ofloo.net/svn/ip2c.tcl/trunk ip2c
#
#
# Now supports ipv6 lookups, reserved ranges are returned with abbreviation ZZ
#
package require ip2c
package require ip
#
# Change the command trigger
#
set trigger "!ip2c"
#
# Change the bind permissions
#
set permis "-|-"
#
# Cookie list
# %2 : Two letter country abbreveration
# %3 : Tree letter country abbreveration
# %c : Full country name
# %i : IP
# %a : Time allocated IP space
# %r : Assinged registry
#
set message_format "Mapped IP \(\002%i\002\) to \(\002%c\002\)"
#
# Error locate for input
# %e : locate input
#
set error_format "No result found for \(\002%e\002\)"
#
# DNS error
# %i : Failed IP
# %h : Failed host
#
set dns_format "Couldn't assosicate an ip with \(\002%h\002\)"
#
# Time output format http://tcl.tk/man/tcl8.5/TclCmd/clock.htm#M26 for more information
#
set time_format {%D}
#
# DO NOT EDIT BELOW
#
set ip-to-country 0.8
proc locate {chan arg} {
global message_format error_format time_format
if {[ip2c::locate -ip $arg]} {
foreach {x} [split $message_format \n] {
if {[string equal {} $x]} {continue}
set i 0
foreach {n} [ip2c::abbr -short] {
array set short [list $i $n]
incr i
}
set i 0
foreach {n} [ip2c::abbr -long] {
array set long [list $i $n]
incr i
}
set i 0
foreach {n} [ip2c::country] {
array set country [list $i $n]
incr i
}
set i 0
foreach {n} [ip2c::country] {
array set country [list $i $n]
incr i
}
set i 0
foreach {n} [ip2c::assigned] {
array set assigned [list $i $n]
incr i
}
set i 0
foreach {n} [ip2c::registry] {
array set registry [list $i $n]
incr i
}
for {set i 0} {$i < [llength [ip2c::assigned]]} {incr i} {
putserv "PRIVMSG $chan :[string trimleft [string map [list \
%2 $short($i) \
%3 $long($i) \
%c [join $country($i)] \
%i [ip2c::address] \
%a [clock format $assigned($i) -format [list $time_format]] \
%r $registry($i) \
] $x]]"
}
}
ip2c::cleanup
} else {
foreach {x} [split $error_format \n] {
if {[string equal {} $x]} {continue}
putserv "PRIVMSG $chan :[string trimleft [string map [list %e $lookup] $x]]"
}
}
}
proc dns_callback {ip host status chan} {
global dns_format
if {$status} {
locate $chan $ip
} else {
foreach {x} [split $dns_format \n] {
if {[string equal {} $x]} {continue}
putserv "PRIVMSG $chan :[string trimleft [string map [list %i $ip %h $host] $x]]"
}
}
}
proc ip2c_proc_pub {nick host hand chan arg} {
set locate [lindex [split $arg] 0]
if {[ip::is ipv4 $locate] || [ip::is ipv6 $locate]} {
locate $chan $locate
} else {
if {[string equal {} $locate]} {
dnslookup [lindex [split [getchanhost $nick] @] end] dns_callback $chan
} else {
dnslookup [lindex [split [getchanhost $locate] @] end] dns_callback $chan
}
}
}
bind pub $permis $trigger ip2c_proc_pub
putlog "Loaded ip-to-country script ${ip-to-country}"
when doing !ip2c IP it works fine
but when I do !ip2c <nick> it returns Tcl error [ip2c_proc_pub]: wrong # args: should be "dnslookup host"
The fact that the dnslookup command only accepts one argument suggests that you are using an eggdrop that predates Dec 26 1999... Which would most likely be a 1.3.x eggdrop?
I think it's safe to say that this script was written for 1.6 eggdrops, and that there'd be a fair deal of work backporting this script for those older branches.
nml375 wrote:The fact that the dnslookup command only accepts one argument suggests that you are using an eggdrop that predates Dec 26 1999... Which would most likely be a 1.3.x eggdrop?
I think it's safe to say that this script was written for 1.6 eggdrops, and that there'd be a fair deal of work backporting this script for those older branches.
That seems rather odd. The dnslookup command in 1.6.20 accepts 2 or more arguments, and uses a callback mechanism. Also, the error message for incorrect arguments looks as follows in 1.6.20
nml375 wrote:That seems rather odd. The dnslookup command in 1.6.20 accepts 2 or more arguments, and uses a callback mechanism. Also, the error message for incorrect arguments looks as follows in 1.6.20
nml375 wrote:Well, that's not a problem with the script, but is due to the fact that the IP address 95.76.180.124 can't be resolved to a dns-name.
* user is user@95.76.180.124 * user
<@me> !ip2c 95.76.180.124
<@bot> Mapped IP (95.76.180.124) to (Romania)
<@me> !ip2c user
<@bot> Couldn't assosicate an ip with (95.76.180.124)
If it probably works doing !ip2c the IP of user shouldn't it also work when doing !ip2c nick? I was expecting !ip2c to return the country of origin of the nick like it does when using the ip of the same person
That would be an issue with either ip2c_proc_pub doing a dns lookup when you already have an IP-address, or in dns_callback bailing out if the dnslookup status is 0 (failed to resolve) even if we still do have the ip address.
Because you can always use my whereis script to get geo-locations of users/IP's/host's. Maybe this will work for you?
<speechles> !whereis 95.76.180.124
<sp33chy> Ip: 95.76.180.124; Country code: RO; Country: Romania; State: Buzau; City: Buzau; Latitude: 45.1500; Longitude: 26.8333; Isp of this ip: UPC Romania SRL; Organization: UPC Romania BUZAU
<sp33chy> Local time in romania: 2012-01-14 20:35
speechles wrote:What type of look-up are you trying to get?
Because you can always use my whereis script to get geo-locations of users/IP's/host's. Maybe this will work for you?
<speechles> !whereis 95.76.180.124
<sp33chy> Ip: 95.76.180.124; Country code: RO; Country: Romania; State: Buzau; City: Buzau; Latitude: 45.1500; Longitude: 26.8333; Isp of this ip: UPC Romania SRL; Organization: UPC Romania BUZAU
<sp33chy> Local time in romania: 2012-01-14 20:35
Yes, that's what I am looking for but your script doesn't seem to be working for me, I keep getting
"95.76.180.124 returns no useful information for me to reply with... ;/"
also when I do !wlogin I get
"Whereis: Account quota appears to have been exceeded...
Whereis: Logout Successful! Never logged in..."