Code: Select all
bind EVNT - init-server conn:init
bind RAW - 302 reslove:raw
bind pub - !test test:pub
proc conn:init { init-server } {
global botnick
putserv "USERNAME $botnick"
}
proc reslove:raw {from key arg} {
global bot_ip
set bot_ip [lindex [split $arg @] 1]
putlog "Succesfully cached ip: \002$bot_ip\002."
}
proc test:pub {nick host hand chan args} {
global bot_ip botnick
if {![info exists bot_ip]} {
putserv "USERNAME $botnick"
return
}
putserv "notice $nick :$bot_ip"
}
Code: Select all
bind EVNT - init-server conn:init
proc conn:init init-server {
global botnick
putserv "USERHOST $botnick"
}
bind RAW - 302 reslove:raw
proc reslove:raw {from key arg} {
global botnick
set bothost [join [lrange $arg 0 end]]
set sbothost [lindex [split $bothost @] 1]
set nslookup [dnslookup $sbothost reslove:ipaddress]
}
proc reslove:ipaddress {ipaddres hostname status} {
set wfile [open "MyIP" "w"]
puts -nonewline $wfile $ipaddres
close $wfile
putlog "Succesfully cached ip: \002$ipaddres\002."
}
proc MyIP {} {
set rfile [open "MyIP" "r"]
set MyIP [read $rfile]
close $rfile
if {"$MyIP" == "" || "$MyIP" == "0.0.0.0"} {
set MyIP ""
foreach a {a b c d e f g h i j k} {
catch {
set external [socket $a.root-servers.net 53]
set MyIP [lindex [fconfigure $external -sockname] 0]
close $external
}
if { ![string equal $MyIP ""] } { break }
}
return $MyIP
} else {
return $MyIP
}
}