| View previous topic :: View next topic |
| Author |
Message |
vladdeh Voice
Joined: 23 Mar 2011 Posts: 33
|
Posted: Mon Jan 09, 2012 2:33 pm Post subject: |
|
|
Could someone please fix this
| Code: | #
# 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" |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Jan 09, 2012 4:36 pm Post subject: |
|
|
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. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
vladdeh Voice
Joined: 23 Mar 2011 Posts: 33
|
Posted: Mon Jan 09, 2012 11:31 pm Post subject: |
|
|
| 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. |
I'm using Eggdrop v1.6.20 :/ |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Jan 10, 2012 1:59 pm Post subject: |
|
|
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
| Code: | | Tcl error: wrong # args: should be "dnslookup ip-address/hostname proc ?args...?" |
Are you using any other scripts that might've replaced the dnslookup command? _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
vladdeh Voice
Joined: 23 Mar 2011 Posts: 33
|
Posted: Fri Jan 13, 2012 6:08 pm Post subject: |
|
|
| 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
| Code: | | Tcl error: wrong # args: should be "dnslookup ip-address/hostname proc ?args...?" |
Are you using any other scripts that might've replaced the dnslookup command? |
Hmm looks like you were right, I had a script that was messing with it, it's fixed now but script is still bugged
This is what I get when I do !ip2c for a nick
<Me> !ip2c Nick
<Bot> Couldn't assosicate an ip with (95.76.180.24)
And this is what I get when I do !ip2c IP
[22:07:12] Tcl error [ip2c_proc_pub]: can't read "lookup": no such variable
Surprinsgly it works properly if I do !ip2c Nick on a nick that has a hostname...doesnt work on a nick that has an IP |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Jan 13, 2012 6:58 pm Post subject: |
|
|
There's an error at these lines:
| Code: | } else {
foreach {x} [split $error_format \n] {
if {[string equal {} $x]} {continue}
putserv "PRIVMSG $chan :[string trimleft [string map [list %e $lookup] $x]]"
}
} |
Most likely, $lookup should've been $arg.
| Code: | } else {
foreach {x} [split $error_format \n] {
if {[string equal {} $x]} {continue}
putserv "PRIVMSG $chan :[string trimleft [string map [list %e $arg] $x]]"
}
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
vladdeh Voice
Joined: 23 Mar 2011 Posts: 33
|
Posted: Fri Jan 13, 2012 7:43 pm Post subject: |
|
|
| nml375 wrote: | There's an error at these lines:
| Code: | } else {
foreach {x} [split $error_format \n] {
if {[string equal {} $x]} {continue}
putserv "PRIVMSG $chan :[string trimleft [string map [list %e $lookup] $x]]"
}
} |
Most likely, $lookup should've been $arg.
| Code: | } else {
foreach {x} [split $error_format \n] {
if {[string equal {} $x]} {continue}
putserv "PRIVMSG $chan :[string trimleft [string map [list %e $arg] $x]]"
}
} |
|
thanks that fixed !ip2c IP but !ip2c nick is still not working
<@me> !ip2c nick
<@Bot> Couldn't assosicate an ip with (95.76.180.124) |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Jan 13, 2012 7:47 pm Post subject: |
|
|
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. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
vladdeh Voice
Joined: 23 Mar 2011 Posts: 33
|
Posted: Fri Jan 13, 2012 8:11 pm Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Jan 13, 2012 8:23 pm Post subject: |
|
|
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. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Jan 14, 2012 2:41 pm Post subject: |
|
|
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?
| Quote: | <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' eggdrop tcl archive |
|
| Back to top |
|
 |
vladdeh Voice
Joined: 23 Mar 2011 Posts: 33
|
Posted: Tue Jan 17, 2012 4:21 pm Post subject: |
|
|
| 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?
| Quote: | <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..."
but the account is newly made :/ |
|
| Back to top |
|
 |
|