Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace eval bla {
- bind pub - !hex [namespace current]::pub
- bind pub - !ip [namespace current]::pub
- #bind join - * [namespace current]::check
- proc pub {nick uhost hand chan text} {
- if {[string is space $text]} {putserv "NOTICE $nick :Usage: $::lastbind <ip/hex-ip>"; return}
- if {$::lastbind == "!hex"} {
- if {![regexp -- {^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$} $text - ip]} {
- putserv "PRIVMSG $chan :Wrong IP."
- return
- }
- putserv "PRIVMSG $chan :$ip = [host2hex $ip]"
- } elseif {$::lastbind == "!ip"} {
- if {![string is xdigit $ip] && [string length $ip] != 8} {
- putserv "PRIVMSG $chan :Wrong Hex-IP."
- return
- }
- putserv "PRIVMSG $chan :$text = [hex2host $text]"
- }
- }
- proc check {nick uhost hand chan} {
- set ident [lindex [split $uhost @] 0]
- set host [lindex [split $uhost @] 1]
- set ident [string trimleft $ident "~^%"]
- if {![string is xdigit $ip] && [string length $ip] != 8} {
- if {[regexp -- {^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$} $host]} {
- putserv "PRIVMSG $chan :$nick > $host > [host2hex $host]"
- return
- } else {
- dnslookup $host [namespace current]::resolve $nick $chan
- return
- }
- } else {
- return
- }
- }
- proc resolve {ip host status nick chan} {
- if {$status != 1} {return}
- if {$host ne $ip} {
- putserv "PRIVMSG $chan :$nick > $host > [host2hex $ip]"
- }
- }
- proc hex2host {host} {
- return [join [scan $host %2x%2x%2x%2x] .]
- }
- proc host2hex {host} {
- set tmp [list]
- foreach _ [split $host .] {
- set h [format %x $_]
- if {[string length $h] == "1"} {
- lappend tmp 0$h
- } else {
- lappend tmp $h
- }
- }
- return [join $tmp ""]
- }
- }
Add Comment
Please, Sign In to add comment