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 

Ipv6dns notice

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


Joined: 17 Apr 2006
Posts: 25

PostPosted: Thu Aug 10, 2006 8:25 pm    Post subject: Ipv6dns notice Reply with quote

Can you help me?i want this script to notice nick not msg chan

Code:
##
#
# ipv6dns.tcl v1.4 - by strikelight ([sL] @ EFNet) (09/25/03)
#
# For eggdrop1.1.5-eggdrop1.6.x
#
# Requires: nslookup tool installed on shell server
#         : bgexec.tcl (available from www.TCLScript.com) to be loaded
#         : BEFORE this script
#
# Contact:
# - E-Mail: strikelight@tclscript.com
# - WWW   : http://www.TCLScript.com
# - IRC   : #Scripting @ EFNet
#
##
#
# Description:
#
# Adds a public command and a dcc command to allow the bot to perform
# dns and reverse lookup of IPv6 hosts and ip's.
#
##
#
# History:
#
# (09/25/03):v1.4  -  Fixed a possible exploit
#
# (10/07/02):v1.3  -  Fixed more checking and utilization of nslookup tool
#                  -  Fixed interpretation of different variations on
#                     the nslookup tool
#
# (09/13/02):v1.2  -  Fixed checking of nslookup tool which could launch an
#                     interactive session of it thus making eggdrop consume
#                     alot of cpu from loading of script
#
#                  -  Changed lookup type to 'AAAA' instead of 'ANY'
#                     for hostnames
#
# (09/12/02):v1.1  -  Added proper formatting to given
#                     ipv6 addresses that contain "::" in them
#                     (that is, insert the necessary 0's to make it
#                     proper format)
#
# (09/05/02):v1.0  -  Initial Release
#
##
#
# Usage:
#
# - Edit the configuration below
#
# - In channel type: !ipv6dns <IPv6-host/ip)
#               ex1: !ipv6dns 3ffe:b80:50f:0:0:0:0:1
#               ex2: !ipv6dns 3ffe:b80:50f::1
#               ex3: !ipv6dns my.host6.net
#
# - From partyline type: .ipv6dns <IPv6-host/ip>
#                   ex1: .ipv6dns 3ffe:b80:50f:0:0:0:0:1
#                   ex2: .ipv6dns 3ffe:b80:50f::1
#                   ex3: .ipv6dns my.host6.net
#
###

## CONFIGURATION ##

# Public command to use to perform ipv6 lookups
set ipv6dns(pubcmd) "!ipv6dns"

# Flag required to use public trigger
# set ipv6dns(pubflag) "o|o"
set ipv6dns(pubflag) "-"

# DCC command to use to perform ipv6 lookups
set ipv6dns(dcccmd) "ipv6dns"

# Flag required to use dcc command
set ipv6dns(dccflag) "o|o"

# Uncomment and set this variable only if script says it can't locate the nslookup tool
# set ipv6dns(nslookup) "/path/to/nslookup"

## END OF CONFIGURATION ##

if {![info exists bgexec(version)]} {
  putlog "Error: bgexec.tcl by strikelight not found."
  putlog "Error: bgexec.tcl is required for ipv6dns.tcl to function properly."
  putlog "Error: You may get bgexec.tcl from http://www.TCLScript.com/"
}

if {[catch {exec nslookup 127.0.0.1}] && [catch {exec nslookup localhost}]} {
  if {[info exists ipv6dns(nslookup)] && ![file exists $ipv6dns(nslookup)]} {
    putlog "Error: ipv6dns(nslookup) variable is set, but is incorrect. ipv6dns.tcl will not function."
  } elseif {![info exists ipv6dns(nslookup)] && [catch {set ipv6dns(nslookup) [exec which nslookup]}]} {
    putlog "Error: nslookup tool does not appear to be installed on this system."
    putlog "Error: nslookup is required for ipv6dns.tcl to function properly."
    putlog "Error: if nslookup IS installed on the system, edit this script, "
    putlog "Error: and change the ipv6dns(nslookup) variable under configuration."
  }
}

bind pub $ipv6dns(pubflag) $ipv6dns(pubcmd) ipv6_pub_dns
bind dcc $ipv6dns(dccflag) $ipv6dns(dcccmd) ipv6_dcc_dns

proc ipv6tonibble {ip {type "int"}} {
  set newip ""
  set nlist ""
  set mlist [split $ip ":"]
  foreach element $mlist {
    if {[string trim $element] == ""} {
      set totzeros [expr 8 - [llength $mlist]]
      for {set i 0} {$i <= $totzeros} {incr i} {
        lappend nlist 0
      }
    } else {
      lappend nlist $element
    }
  }
  for {set i [expr [llength $nlist] - 1]} {$i >= 0} {incr i -1} {
    set seg [lindex $nlist $i]
    for {set j 0} {$j < 4} {incr j} {
      if {$seg != ""} {
        append newip "[string index $seg [expr [string length $seg] - 1]]."
        if {[string length $seg] > 1} {
          set seg [string range $seg 0 [expr [string length $seg] - 2]]
        } else {
          set seg ""
        }
      } else {
        append newip "0."
      }
    }
  }
  append newip "ip6.$type"
  return $newip
}

proc ipv6_remove_queue {who} {
  global ipv6dns
  set dloc [lsearch $ipv6dns(queue) $who]
  if {$dloc != -1} {set ipv6dns(queue) [lreplace $ipv6dns(queue) $dloc $dloc]}
}

proc ipv6_callback {type where who orig ip6type input} {
  global botnick ipv6dns
  set result ""
  if {![info exists ipv6dns(nslookup)]} {
    set cmd "nslookup"
  } else {
    set cmd $ipv6dns(nslookup)
  }
  set fnd 0
  foreach line [split $input "\n"] {
    if {[string match "*ip6.\[int|arpa\]*name*=*" $line] || [string match "*IPv6 address*=*" $line]} {
      set result [string trim [lindex [split $line "="] 1]]
      break
    } elseif {[string match "*has AAAA*" $line]} {
      set result [lindex [split $line] [expr [llength [split $line]] - 1]]
      break
    } elseif {[string match "*Name:*" $line]} {
      set name [lindex [split $line] [expr [llength [split $line]] - 1]]
      if {[string tolower $name] == [string tolower $orig]} {
        set fnd 1
      }
    } elseif {($fnd) && ([string match "*Address:*" $line])} {
      set result [lindex [split $line] [expr [llength [split $line]] - 1]]
      break
    }
  }
  if {($result == "") && ($ip6type == 1) && ([string match "*:*" $orig])} {
    set lookup [ipv6tonibble $orig arpa]
    if {[catch {bgexec "$cmd -type=any $lookup" [list ipv6_callback $type $where $who $orig 2]} err]} {
      set result ""
    } else {
      return
    }
  }
  if {($result != "") && ([string index $result [expr [string length $result] - 1]] == ".")} {
    set result [string range $result 0 [expr [string length $result] - 2]]
  }
  if {$result == ""} { set result "Error during lookup, or lookup impossible." }
  if {$type == "dcc"} {
    if {[valididx $where]} {
      putidx $where "\[\002ipv6\002] $orig = $result"
      ipv6_remove_queue $who
      return
    }
  } elseif {$type == "pub"} {
    if {[onchan $botnick $where]} {
      puthelp "PRIVMSG $where :\[\002ipv6\002] \037$who\037: $orig = $result"
      ipv6_remove_queue $who
      return
    }
  }
}

proc ipv6_pub_dns {nick uhost hand chan text} {
  global ipv6dns
  if {$hand == "*"} {
    set who [string tolower $nick]
  } else {
    set who [string tolower $hand]
  }
  if {![info exists ipv6dns(nslookup)]} {
    set cmd "nslookup"
  } else {
    set cmd $ipv6dns(nslookup)
  }
  if {[lsearch $ipv6dns(queue) $who] != -1} {
    puthelp "NOTICE $nick :You already have a request in queue, please wait."
    return
  }
  set orig [lindex $text 0]
  if {$orig == ""} {
    puthelp "NOTICE $nick :Usage: $ipv6dns(pubcmd) <host/ipv6>"
    return
  }
  regsub -all {[^a-zA-Z0-9:.\-]} $orig "" orig
  if {![string match "*\[:.\]*" $orig]} {
    puthelp "NOTICE $nick :$orig does not appear to be a valid host/ipv6 address."
    return
  }
  if {[string match "*:*" $orig]} {
    set lookup [ipv6tonibble $orig]
    set atype "any"
    set ptype "1"
  } else {
    set lookup $orig
    set atype "AAAA"
    set ptype "0"
  }
  if {[catch {bgexec "$cmd -type=$atype $lookup" [list ipv6_callback pub $chan $who $orig $ptype]} err]} {
    puthelp "PRIVMSG $chan :Error during execution of nslookup."
    return
  }
  puthelp "NOTICE $nick :Processing your request, one moment..."
  lappend ipv6dns(queue) $who
  utimer 15 [list ipv6_remove_queue $who]
}

proc ipv6_dcc_dns {hand idx text} {
  global ipv6dns
  set who [string tolower $hand]
  if {![info exists ipv6dns(nslookup)]} {
    set cmd "nslookup"
  } else {
    set cmd $ipv6dns(nslookup)
  }
  if {[lsearch $ipv6dns(queue) $who] != -1} {
    putidx $idx "You already have a request in queue, please wait."
    return 0
  }
  set orig [lindex $text 0]
  if {$orig == ""} {
    putidx $idx "Usage: $ipv6dns(dcccmd) <host/ipv6>"
    return 0
  }
  regsub -all {[^a-zA-Z0-9:.\-]} $orig "" orig
  if {![string match "*\[:.\]*" $orig]} {
    putidx $idx "$orig does not appear to be a valid host/ipv6 address."
    return 1
  }
  if {[string match "*:*" $orig]} {
    set lookup [ipv6tonibble $orig]
    set ptype "1"
  } else {
    set lookup $orig
    set ptype "0"
  }
  if {[catch {bgexec "$cmd -type=any $lookup" [list ipv6_callback dcc $idx $who $orig $ptype]} err]} {
    putidx $idx "Error during execution of nslookup."
    return
  }
  putidx $idx "Processing your request, one moment..."
  lappend ipv6dns(queue) $who
  utimer 15 [list ipv6_remove_queue $who]
  return 1
}

if {![info exists ipv6dns(queue)]} { set ipv6dns(queue) "" }
set ipv6dns(version) "1.4"

putlog "ipv6dns.tcl v$ipv6dns(version) by strikelight now loaded."


tnx
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Thu Aug 10, 2006 8:55 pm    Post subject: Reply with quote

Change each instance of:
Code:
puthelp "PRIVMSG $chan : ..... "

.. to ..
Code:
puthelp "PRIVMSG $nick : ..... "

_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
Snorly
Voice


Joined: 17 Apr 2006
Posts: 25

PostPosted: Thu Aug 10, 2006 9:13 pm    Post subject: Reply with quote

its not working and i want notice Smile and here is the problem

Code:
  } elseif {$type == "pub"} {
    if {[onchan $botnick $where]} {
      puthelp "PRIVMSG $where :\[\002ipv6\002] \037$who\037: $orig = $result"
      ipv6_remove_queue $who
      return
    }
  }
}
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Thu Aug 10, 2006 9:34 pm    Post subject: Reply with quote

Then simply change "PRIVMSG" to "NOTICE".
My apologies for misreading your original post. Embarassed
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
Snorly
Voice


Joined: 17 Apr 2006
Posts: 25

PostPosted: Fri Aug 11, 2006 5:54 am    Post subject: Reply with quote

He he np if i give NOTICE it notices all users in channel. I want only to notice user that uses !ipv6dns Smile

and if i change this
Code:
puthelp "PRIVMSG $where :\[\002ipv6\002] \037$who\037: $orig = $result"


in to
Code:

puthelp "NOTICE $nick :\[\002ipv6\002] \037$who\037: $orig = $result"


its not working
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Fri Aug 11, 2006 8:25 am    Post subject: Reply with quote

Try:

Code:
  } elseif {$type == "pub"} {
      if {[validuser $who]} {
        puthelp "NOTICE [hand2nick $who] :\[\002ipv6\002] \037$who\037: $orig = $result"
      } else {
        puthelp "NOTICE $who :\[\002ipv6\002] \037$who\037: $orig = $result"
      }
      ipv6_remove_queue $who
      return
    }
  }
}


might work, might not...
_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Fri Aug 11, 2006 9:06 am    Post subject: Reply with quote

simply change

Code:
if {[catch {bgexec "$cmd -type=$atype $lookup" [list ipv6_callback pub $chan $who $orig $ptype]} err]} {


to

Code:
if {[catch {bgexec "$cmd -type=$atype $lookup" [list ipv6_callback pub $nick $who $orig $ptype]} err]} {


and don't forget to use the NOTICE instead of PRIVMSG.
Back to top
View user's profile Send private message
Snorly
Voice


Joined: 17 Apr 2006
Posts: 25

PostPosted: Fri Aug 11, 2006 7:06 pm    Post subject: Reply with quote

nothing works Sad
eny other ideas?
Back to top
View user's profile Send private message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Sat Aug 12, 2006 3:44 am    Post subject: Reply with quote

define "Nothing works".
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