DoctorD90

ErrorReporter.tcl 1.2.0

May 15th, 2013
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 3.21 KB | None | 0 0
  1. ### ErrorReporter.tcl 1.2.0 MDL5RT8X
  2.  
  3. #SUGGESTED
  4. # PBinSrc.tcl fMrtKqyq
  5. # TCLLoader.tcl smApj15u
  6.  
  7. #LICENSE
  8. # Copyright © 2013 Alberto Dietze "DoctorD90"
  9. #
  10. #    This program is free software: you can redistribute it and/or modify
  11. #    it under the terms of the GNU General Public License as published by
  12. #    the Free Software Foundation, either version 3 of the License, or
  13. #    (at your option) any later version.
  14. #
  15. #    This program is distributed in the hope that it will be useful,
  16. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. #    GNU General Public License for more details.
  19. #
  20. #    You should have received a copy of the GNU General Public License
  21. #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  22. #
  23. # Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt
  24.  
  25. #PATERNITY
  26. #Coder: DoctorD90
  27. #Network: irc.OnlineGamesNet.net
  28. #Chan: #eHito
  29. #Script's List: www.EggTcl.tk
  30. #
  31. #Thanks to guys on #egghelp on irc.freenode.net
  32. #Special thanks to Thommey and Speechles
  33.  
  34. #PURPOSE
  35. #Get error from irc instead of partyline.
  36. #Settable if reset error after get it.
  37.  
  38. #USAGE
  39. #Use commands that you set in SETTINGS section.
  40.  
  41. #SETTINGS
  42. #Set flag of allowed people to use public setting command.
  43. set errrep(pflags) "n"
  44. #Set flag of allowed people to use query setting command.
  45. set errrep(qflags) "n"
  46. #Set public command to get clear error.
  47. set errrep(pset) ".errcls"
  48. #Set query command to get clear error.
  49. set errrep(qset) ".errcls"
  50. #Set where store log file.
  51. set errrep(dir) "text/"
  52. #Set flag of allowed people to use public commands.
  53. set errrep(pflagc) "n"
  54. #Set flag of allowed people to use query command.
  55. set errrep(qflagc) "n"
  56. #Set public command to get last error.
  57. set errrep(pcmd) ".err"
  58. #Set query command to get last error.
  59. set errrep(qcmd) ".err"
  60.  
  61.  
  62. ### DON'T EDIT ANYTHING BELOW ###
  63.  
  64. if {[file exists " ${::errrep(dir)}err.rep"]} {
  65.   set ::errrep(cls) 1
  66. } else {
  67.   set ::errrep(cls) 0
  68. }
  69.  
  70. bind pub $errrep(pflags) $errrep(pset) pub_errset
  71. proc pub_errset {nick uhost hand chan text} {
  72.   err_set $nick
  73. }
  74.  
  75. bind msg $errrep(qflags) $errrep(qset) msg_errset
  76. proc msg_errset {nick uhost hand text} {
  77.   err_set $nick
  78. }
  79.  
  80. proc err_set {nick} {
  81.   if {[file exists "${::errrep(dir)}err.rep"]} {
  82.     file delete -force "${::errrep(dir)}err.rep"
  83.     set ::errrep(cls) 0
  84.     set msg "Dis"
  85.   } else {
  86.     set fs [open "${::errrep(dir)}err.rep" w]
  87.     close $fs
  88.     set ::errrep(cls) 1
  89.     set msg "En"
  90.   }
  91.   putserv "NOTICE $nick :\002ErrorReporter:\002 Clear ErrorInfo ${msg}abled."
  92. }
  93.  
  94. bind pub $errrep(pflagc) $errrep(pcmd) pub_errget
  95. proc pub_errget {nick uhost hand chan text} {
  96.   err_get $nick
  97. }
  98.  
  99. bind msg $errrep(qflagc) $errrep(qcmd) msg_errget
  100. proc msg_errget {nick uhost hand text} {
  101.   err_get $nick
  102. }
  103.  
  104. proc err_get {nick} {
  105.   if {![info exists ::errorInfo]} {
  106.     putserv "NOTICE $nick :There is not error, yet."
  107.   } else {
  108.     foreach line [split $::errorInfo \n] {
  109.       putserv "NOTICE $nick :$line"
  110.     }
  111.     putserv "NOTICE $nick :*END*"
  112.     if {$::errrep(cls)} {
  113.       unset ::errorInfo
  114.     }
  115.   }
  116. }
  117.  
  118. ###
  119. putlog "ErrorReporter.tcl LOADED"
Advertisement