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.

Need help with IPinfo Script

Help for those learning Tcl or writing their own scripts.
n
nobody
Voice
Posts: 19
Joined: Fri Apr 03, 2020 10:01 pm

Post by nobody »

sysusr wrote:Forgot to reply back. Script works flawless now. Thank you
can you post the complete working script here bro , if you don't mind?
πŸ††πŸ…·πŸ…΄πŸ…½ πŸ…½πŸ…ΎπŸ†ƒπŸ…·πŸ…ΈπŸ…½πŸ…Ά πŸ…ΆπŸ…ΎπŸ…΄πŸ†‚ πŸ†πŸ…ΈπŸ…ΆπŸ…·πŸ†ƒ, πŸ…ΆπŸ…Ύ πŸ…»πŸ…΄πŸ…΅πŸ†ƒ!
s
simo
Revered One
Posts: 1080
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Code: Select all


package require http
package require json

bind pub m|- !ginfo Pub:Geo:INFO

proc Pub:Geo:INFO {nick uhost hand chan text} {
   if {[scan $text {%s} lookup] != 1} {
      puthelp "NOTICE $nick :Error, syntax is: !Ginfo <ip>"
      return
   }
   if {![regexp {([0-9]+\.)([0-9]+\.)([0-9]+\.)([0-9]+)} $lookup]} {
      puthelp "NOTICE $nick :Error, the IP you mentioned is not valid."
      return
   }
   catch {set http [::http::geturl http://ipinfo.io/$lookup/json -timeout 6000]} error
   set data [::http::data $http]
   set json [::json::json2dict $data]
   ::http::cleanup $http
   set keys [dict keys $json]
   foreach ele {ip hostname city region country loc postal phone org} {
      set $ele [expr {[lsearch $keys $ele] > -1 ? [dict get $json $ele] : "n/a"}]
   }
   puthelp "NOTICE $nick :IP: $ip - Hostname: $hostname - City: $city - Region: $region - Country: $country - Location: $loc - Organization: $org"
}

User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

And the version that uses ip library to do the IP v4 and v6 validation rather than that regexp that won't match IP v6:

Code: Select all

package require http
package require json
package require ip

bind raw - NOTICE server:notices

proc server:notices {from keyword text} {
	if {![string match -nocase "*client connecting*" $text]} return
	set lookup [lindex [split $text] 6]
	if {[::ip::version $lookup] < 4} return
	catch {set http [::http::geturl http://ipinfo.io/$lookup/json -timeout 6000]} error
	set data [::http::data $http]
	set json [::json::json2dict $data]
	::http::cleanup $http
	set keys [dict keys $json]
	foreach ele {ip hostname city region country loc postal phone org} {
		set $ele [expr {[lsearch $keys $ele] > -1 ? [dict get $json $ele] : "n/a"}]
	}
	puthelp "PRIVMSG #Opers :$nick -  $ip - $country"
}
Once the game is over, the king and the pawn go back in the same box.
n
nobody
Voice
Posts: 19
Joined: Fri Apr 03, 2020 10:01 pm

Post by nobody »

this is good for ircop?
πŸ††πŸ…·πŸ…΄πŸ…½ πŸ…½πŸ…ΎπŸ†ƒπŸ…·πŸ…ΈπŸ…½πŸ…Ά πŸ…ΆπŸ…ΎπŸ…΄πŸ†‚ πŸ†πŸ…ΈπŸ…ΆπŸ…·πŸ†ƒ, πŸ…ΆπŸ…Ύ πŸ…»πŸ…΄πŸ…΅πŸ†ƒ!
n
nobody
Voice
Posts: 19
Joined: Fri Apr 03, 2020 10:01 pm

weird

Post by nobody »

how to see errors?

<guy> witch rehash
-witch- Reloading scripts/settings..
<guy> !test
-witch- Error, syntax is: !Ginfo <ip>
<guy> !test 1.1.1.1


- no response at all im currently using blackip.tcl using ip-info.com service but i found ipinfo.io near to accurate.
πŸ††πŸ…·πŸ…΄πŸ…½ πŸ…½πŸ…ΎπŸ†ƒπŸ…·πŸ…ΈπŸ…½πŸ…Ά πŸ…ΆπŸ…ΎπŸ…΄πŸ†‚ πŸ†πŸ…ΈπŸ…ΆπŸ…·πŸ†ƒ, πŸ…ΆπŸ…Ύ πŸ…»πŸ…΄πŸ…΅πŸ†ƒ!
User avatar
BLaCkShaDoW
Op
Posts: 117
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

Re: weird

Post by BLaCkShaDoW »

Hello, why do you say that ipinfo.io is more accurate then the the source from BlackIP.tcl ?
BLaCkShaDoW Production @ WwW.TclScripts.Net
n
nobody
Voice
Posts: 19
Joined: Fri Apr 03, 2020 10:01 pm

Re: weird

Post by nobody »

good morning, because that's my opinion when i tried checking the ip on both website.
πŸ††πŸ…·πŸ…΄πŸ…½ πŸ…½πŸ…ΎπŸ†ƒπŸ…·πŸ…ΈπŸ…½πŸ…Ά πŸ…ΆπŸ…ΎπŸ…΄πŸ†‚ πŸ†πŸ…ΈπŸ…ΆπŸ…·πŸ†ƒ, πŸ…ΆπŸ…Ύ πŸ…»πŸ…΄πŸ…΅πŸ†ƒ!
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The command is !ginfo ip not !test ip, unless you changed the command from !ginfo to !test.
Once the game is over, the king and the pawn go back in the same box.
R
RoKiTo
Voice
Posts: 17
Joined: Thu Jul 22, 2021 3:07 pm

Post by RoKiTo »

Will you be able to adapt this api please caesar :D
https://proxycheck.io/v2/2806:10be:a:76 ... :6b6c:7a23
{
"status": "ok",
"2806:10be:a:7699:e094:f36d:6b6c:7a23": {
"proxy": "no",
"type": "Business"
}
}
Post Reply