egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

whois info by JeFFOsZ

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
abah
Voice


Joined: 01 Dec 2013
Posts: 39
Location: Indonesia

PostPosted: Sun Sep 23, 2018 6:50 am    Post subject: whois info by JeFFOsZ Reply with quote

can anyone help me so that the script from JeFFOsZ whoisinfo can use .chanset so that only certain channels can function

Code:
set whoisinfo(version) "20.18"
set whoisinfo(trigger) "!infoip"
set whoisinfo(port) 43
set whoisinfo(ripe) "whois.ripe.net"
set whoisinfo(arin) "whois.arin.net"
set whoisinfo(apnic) "whois.apnic.net"
set whoisinfo(lacnic) "whois.lacnic.net"
set whoisinfo(afrinic) "whois.afrinic.net"

bind pub - $whoisinfo(trigger) pub_whoisinfo

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 :2Range: 04$query(range) |02 Netname: 14$query(netname) | Organisation: 10$query(orgname) |02 Country: 15$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."
Back to top
View user's profile Send private message
willyw
Owner


Joined: 15 Jan 2009
Posts: 975

PostPosted: Sun Sep 23, 2018 5:01 pm    Post subject: Re: whois info by JeFFOsZ Reply with quote

1.) Reference: http://forum.egghelp.org/viewtopic.php?p=98054#98054
2.) This is untested.
3.) The edits are marked by comments, to you can find them easily.
Code:
set whoisinfo(version) "20.18"
set whoisinfo(trigger) "!infoip"
set whoisinfo(port) 43
set whoisinfo(ripe) "whois.ripe.net"
set whoisinfo(arin) "whois.arin.net"
set whoisinfo(apnic) "whois.apnic.net"
set whoisinfo(lacnic) "whois.lacnic.net"
set whoisinfo(afrinic) "whois.afrinic.net"

bind pub - $whoisinfo(trigger) pub_whoisinfo

##  Here's the first line to add
setudef flag whoisinfo


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 :2Range: 04$query(range) |02 Netname: 14$query(netname) | Organisation: 10$query(orgname) |02 Country: 15$query(country)"
}

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

### Here's the second edit.
        if {![channel get $chan whoisinfo]} {
              return 0
           }
###  end of additional lines #####   


   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."

_________________
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
Back to top
View user's profile Send private message
abah
Voice


Joined: 01 Dec 2013
Posts: 39
Location: Indonesia

PostPosted: Fri Sep 28, 2018 6:50 am    Post subject: Reply with quote

Thank you for the response. Your solution is correct willy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber