Advertisement
Ford

ipinfo tcl / debug code

Aug 20th, 2011
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. ##############################################################################################
  2. ## ## Ipinfo.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ##
  3. ##############################################################################################
  4. ## To use this script you must set channel flag +ipinfo (ie .chanset #chan +ipinfo) ##
  5. ##############################################################################################
  6. ##############################################################################################
  7. ## ## Start Setup. ## ##
  8. ##############################################################################################
  9. ## Change the character between the "" below to change the command character/trigger. ##
  10. set Ipinfocmdchar "!"
  11. proc Ipinfo {nick host hand chan search} {
  12. if {[lsearch -exact [channel info $chan] +ipinfo] != -1} {
  13. ## Change the format codes between the "" below to change the color/state of the text. ##
  14. set titlef "\0034"
  15. set textf "\003\002"
  16. ##############################################################################################
  17. ## ## End Setup. ## ##
  18. ##############################################################################################
  19. set Ipinfosite "www.melissadata.com"
  20. if {$search == ""} {
  21. putserv "PRIVMSG $chan :${textf}You must provide an ip address to check!"
  22. } else {
  23. set Ipinfourl "/lookups/iplocation.asp?ipaddress=${search}"
  24. if {[catch {set Ipinfosock [socket -async $Ipinfosite 80]} sockerr]} {
  25. putlog "$Ipinfosite $Ipinfourl $sockerr error"
  26. return 0
  27. } else {
  28. puts $Ipinfosock "GET $Ipinfourl HTTP/1.0"
  29. puts $Ipinfosock "Host: $Ipinfosite"
  30. puts $Ipinfosock "User-Agent: Opera 9.6"
  31. puts $Ipinfosock ""
  32. flush $Ipinfosock
  33. while {![eof $Ipinfosock]} {
  34. set Ipinfovar " [gets $Ipinfosock] "
  35. if {[regexp {<div align='center' class='Lookupserror'>([^<]*)<b>([^<]*)<\/b>([^<]*)<br>([^<]*)<\/div>} $Ipinfovar]} {
  36. putserv "PRIVMSG $chan : ${titlef}Syntax error: ${textf}Ip must be in the form of 1.2.3.4"
  37. close $Ipinfosock
  38. return 0
  39. } elseif {[regexp {<td class='columresult'>([^<]*)<\/td><td align='left'><b>([^<]*)<\/b><\/td><\/tr>} $Ipinfovar]} {
  40. set IPResult [regexp -all -inline {<td class='columresult'>([^<]*)<\/td><td align='left'><b>([^<]*)<\/b><\/td><\/tr>} $Ipinfovar]
  41. set IPResults "${titlef}[lindex $IPResult {1}]: ${textf}[lindex $IPResult {2}] [lindex $IPResult {3}]"
  42. putserv "PRIVMSG $chan : [ipinforecode $IPResults]"
  43. }
  44. }
  45. close $Ipinfosock
  46. return 0
  47. }
  48. }
  49. }
  50. }
  51. proc ipinforecode { textin } {
  52. return [string map {&quot; \" &middot; · &amp; & &nbsp; ""} $textin]
  53. }
  54. bind pub - ${Ipinfocmdchar}ipinfo Ipinfo
  55. setudef flag ipinfo
  56. putlog "Ipinfo Script by Ford_Lawnmower successfully loaded! irc.geekshed.net #Script-Help"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement