Guest User

Untitled

a guest
Feb 19th, 2018
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.57 KB | None | 0 0
  1. namespace eval bla {
  2.  
  3. bind pub - !hex [namespace current]::pub
  4. bind pub - !ip [namespace current]::pub
  5.  
  6. #bind join - * [namespace current]::check
  7.  
  8. proc pub {nick uhost hand chan text} {
  9.  
  10. if {[string is space $text]} {putserv "NOTICE $nick :Usage: $::lastbind <ip/hex-ip>"; return}
  11.  
  12. if {$::lastbind == "!hex"} {
  13. if {![regexp -- {^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$} $text - ip]} {
  14. putserv "PRIVMSG $chan :Wrong IP."
  15. return
  16. }
  17. putserv "PRIVMSG $chan :$ip = [host2hex $ip]"
  18.  
  19. } elseif {$::lastbind == "!ip"} {
  20.  
  21. if {![string is xdigit $ip] && [string length $ip] != 8} {
  22. putserv "PRIVMSG $chan :Wrong Hex-IP."
  23. return
  24. }
  25.  
  26. putserv "PRIVMSG $chan :$text = [hex2host $text]"
  27. }
  28.  
  29. }
  30.  
  31. proc check {nick uhost hand chan} {
  32.  
  33. set ident [lindex [split $uhost @] 0]
  34. set host [lindex [split $uhost @] 1]
  35. set ident [string trimleft $ident "~^%"]
  36.  
  37. if {![string is xdigit $ip] && [string length $ip] != 8} {
  38.  
  39. if {[regexp -- {^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$} $host]} {
  40.  
  41. putserv "PRIVMSG $chan :$nick > $host > [host2hex $host]"
  42. return
  43. } else {
  44.  
  45. dnslookup $host [namespace current]::resolve $nick $chan
  46. return
  47. }
  48.  
  49. } else {
  50.  
  51. return
  52. }
  53. }
  54.  
  55. proc resolve {ip host status nick chan} {
  56. if {$status != 1} {return}
  57. if {$host ne $ip} {
  58. putserv "PRIVMSG $chan :$nick > $host > [host2hex $ip]"
  59. }
  60. }
  61.  
  62. proc hex2host {host} {
  63. return [join [scan $host %2x%2x%2x%2x] .]
  64. }
  65.  
  66. proc host2hex {host} {
  67. set tmp [list]
  68. foreach _ [split $host .] {
  69. set h [format %x $_]
  70. if {[string length $h] == "1"} {
  71. lappend tmp 0$h
  72. } else {
  73. lappend tmp $h
  74. }
  75. }
  76. return [join $tmp ""]
  77. }
  78.  
  79.  
  80. }
Add Comment
Please, Sign In to add comment