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.

whoisinfo.tcl help

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

whoisinfo.tcl help

Post by spithash »

I am having an "Error" in both of my bots (running from the same machine when I try to trigger this script, could someone help around? or if anyone has a similar script, that would be very very useful to me...

Code: Select all

##############################
# whoisinfo.tcl v0.1
##############################

##############################
# SETTINGS
##############################

# version
set whoisinfo(version) "0.1"

# trigger
set whoisinfo(trigger) "!ip"

# whois port
set whoisinfo(port) 43

# ripe server
set whoisinfo(ripe) "whois.ripe.net"

# arin server
set whoisinfo(arin) "whois.arin.net"

# apnic server
set whoisinfo(apnic) "whois.apnic.net"

# lacnic server
set whoisinfo(lacnic) "whois.lacnic.net"

# afrinic server
set whoisinfo(afrinic) "whois.afrinic.net"

##############################
# BINDS
##############################

bind pub - $whoisinfo(trigger) pub_whoisinfo

##############################
# CODE
##############################

proc whoisinfo_setarray {} {
	global query

	set query(netname) "(none)"
	set query(country) "(none)"
	set query(orgname) "(none)"
	set query(orgid) "(none)"
	set query(range) "(none)"
}

proc whoisinfo_display { chan } {
	global query

	putlog "Firstline: $query(firstline)"

	puthelp "PRIVMSG $chan :\[\002IP Whois\002\] Range: $query(range), Netname: $query(netname), Organisation: $query(orgname), Country: $query(country)"
}

proc pub_whoisinfo {nick uhost handle chan search} {
	global whoisinfo
	global query

	whoisinfo_setarray 

	if {[whoisinfo_whois $whoisinfo(arin) $search]==1} {
		if {[string compare [string toupper $query(orgid)] "RIPE"]==0} {
			if {[whoisinfo_whois $whoisinfo(ripe) $search]==1} {
				whoisinfo_display $chan
			}
		 } elseif {[string compare [string toupper $query(orgid)] "APNIC"]==0} {
			if {[whoisinfo_whois $whoisinfo(apnic) $search]==1} {
				whoisinfo_display $chan
			}
		 } elseif {[string compare [string toupper $query(orgid)] "LACNIC"]==0} {
			if {[whoisinfo_whois $whoisinfo(lacnic) $search]==1} {
				whoisinfo_display $chan
				}
		 } elseif {[string compare [string toupper $query(orgid)] "AFRINIC"]==0} {
			if {[whoisinfo_whois $whoisinfo(afrinic) $search]==1} {
				whoisinfo_display $chan
				}
		 } else {
			whoisinfo_display $chan
		}
	} else {
		if { [info exist query(firstline)] } {
			puthelp "PRIVMSG $chan :\[\002Whois\002\] Firstline: $query(firstline)"
		} else {
			puthelp "PRIVMSG $chan :\[\002Whois\002\] Error?"
		}
	}
}

proc whoisinfo_whois {server search} {
	global whoisinfo
	global query
	set desccount 0
	set firstline 0
	set reply 0
		
	putlog "Whois: $server:$whoisinfo(port) -> $search"

	if {[catch {set sock [socket -async $server $whoisinfo(port)]} sockerr]} {
      	puthelp "PRIVMSG $chan :\[\002Whois\002\] Error: $sockerr. Try again later."
      	close $sock
		return 0
    	}
	
	puts $sock $search
	flush $sock

	while {[gets $sock whoisline]>=0} {

		putlog "Whois: $whoisline"

		if {[string index $whoisline 0]!="#" && [string index $whoisline 0]!="%" && $firstline==0} {
			if {[string trim $whoisline]!=""} {
				set query(firstline) [string trim $whoisline]
				set firstline 1
			}
		}

		if {[regexp -nocase {netname:(.*)} $whoisline all item]} {
			set query(netname) [string trim $item]
			set reply 1
		} elseif {[regexp -nocase {owner-c:(.*)} $whoisline all item]} {
			set query(netname) [string trim $item]
			set reply 1 
		} elseif {[regexp -nocase {country:(.*)} $whoisline all item]} {
			set query(country) [string trim $item]
			set reply 1
		} elseif {[regexp -nocase {descr:(.*)} $whoisline all item] && $desccount==0} {
			set query(orgname) [string trim $item]
			set desccount 1
			set reply 1
		} elseif {[regexp -nocase {orgname:(.*)} $whoisline all item]} {
			set query(orgname) [string trim $item]
			set reply 1
		} elseif {[regexp -nocase {owner:(.*)} $whoisline all item]} {
			set query(orgname) [string trim $item]
			set reply 1
		} elseif {[regexp -nocase {orgid:(.*)} $whoisline all item]} {
			set query(orgid) [string trim $item]
			set reply 1
		} elseif {[regexp -nocase {inetnum:(.*)} $whoisline all item]} {
			set query(range) [string trim $item]
			set reply 1
		} elseif {[regexp -nocase {netrange:(.*)} $whoisline all item]} {
			set query(range) [string trim $item]
			set reply 1
		}
	}

	close $sock
	
	return $reply
}

putlog "whoisinfo.tcl v$whoisinfo(version) by JeFFOsZ: loaded."
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
CrazyCat
Revered One
Posts: 1334
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I'd just copy/paste your source in a file, loaded it and tryed:
14:51:30 <@CrazyCat> !ip 93.24.58.127
14:51:31 <@Artus> [IP Whois] Range: 93.24.0.0 - 93.27.255.255, Netname: N9UF-DYN-DSL, Organisation: Dynamic pools, Country: FR
Artus is eggdrop 1.6.21

What's the error you get ? On wich eggdrop version ?
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

the error I get is just

Code: Select all

<@nagger> Error
My name is nagger and I am running eggdrop v1.8.0+preinit, on Linux 3.11.0.
But I've tried it on v1.6.21 too with the same error...
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
CrazyCat
Revered One
Posts: 1334
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

And what in party-line ?
And what's the IP you tried ?
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

I just tried the IP you tried
[16:13:27] <@spithash> !ipwhois 93.24.58.127
[16:13:42] <@nagger> [Whois] Error?
here's the party line

Code: Select all

[16:13] Whois: whois.arin.net:43 -> 93.24.58.127
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
CrazyCat
Revered One
Posts: 1334
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

It seems you cannot join the arin server.

Did you try to telnet it (on port 43) from you shell ?
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

Code: Select all

telnet> open whois.arin.net 43
Trying 199.71.0.48...
Connected to whois.arin.net.
Escape character is '^]'.
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Post Reply