anticheat_buggy_dont_use_it.tcl 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. # AntiStatCheat v1.2.0
  2. # this script is intended for use with stats.mod
  3. # (http://www.visions-of-fantasy.de/stats.mod/)
  4. # This script should prevent any cheating attempts
  5. # Depending on the configuration, it either doesn't increase
  6. # the stats during the cheat attempt, subtracts the words
  7. # or does nothing at all and calculates the stats as usual.
  8. # Cheating attempts get logged to a certain loglevel (2 by default)
  9. # set your console to +2 and the channel you want to monitor to
  10. # watch the bots reaction on cheating attempts.
  11. ### CONFIGURATION ###
  12. # if a user talks more than x lines in a row without another
  13. # user interfering, then he or she is probably trying to cheat
  14. set acset(monologue) 7
  15. # the following settings control the way how the bot should react
  16. # on different cheating attempts.
  17. # 0: do nothing
  18. # 1: don't increase the stats
  19. # 2: subtract words
  20. # Repeating: This is usually a real cheating attempt, so the default
  21. # treatment is subtracting the words.
  22. set acset(repeatpunish) 2
  23. # Monologue: This is also a strong indication of a cheating attempt.
  24. set acset(monologuepunish) 2
  25. # Colors: Users who use colors aren't necessarly cheating, so just
  26. # don't increase the stats and don't punish them.
  27. set acset(colorpunish) 1
  28. # if the average wordlength in a line is smaller than this value, then
  29. # someone probably tried to cheat ("a a a a a a")
  30. set acset(wlen) 2.0
  31. #
  32. set acset(wlenpunish) 1
  33. # the loglevel where the bot logs the cheating attempts to
  34. set acset(loglev) 2
  35. # the time in seconds for that the bot remembers what the user has spoken
  36. # to detect repeating.
  37. set acset(tracktime) 240
  38. ### END OF CONFIGURATION ###
  39. catch "unbind pubm - * *pubm:stat"
  40. bind pubm - * pubm:stat
  41. proc pubm:stat {nick uhost hand chan rest} {
  42. if {![stat:cheated $nick $hand $chan $rest words]} {
  43. *pubm:stat $nick $uhost $hand $chan $rest
  44. }
  45. }
  46. catch "unbind ctcp - ACTION *ctcp:stat"
  47. bind ctcp - ACTION ctcp:stat
  48. proc ctcp:stat {nick uhost hand chan key rest} {
  49. if {![stat:cheated $nick $hand $chan $rest action]} {
  50. *ctcp:stat $nick $uhost $hand $chan $key $rest
  51. }
  52. }
  53. proc stat:cheated {nick hand chan rest type} {
  54. global acset
  55. stat:resetstuff
  56. set hand [nick2suser $nick $chan]
  57. if {$hand == "*"} {
  58. stat:monologue $hand $chan
  59. return 1
  60. }
  61. if {$acset(repeatpunish) != 0} {
  62. if {[stat:repeated $hand $chan $rest]} {
  63. if {$acset(repeatpunish) == 2} {
  64. putloglev $acset(loglev) $chan "StatCheat: $hand is repeating. Subtracting words instead of adding."
  65. incrstats $hand $chan words -[llength $rest]
  66. incrstats $hand $chan lines -1
  67. if {$type == "action"} {
  68. incrstats $hand $chan actions -1
  69. }
  70. } else {
  71. putloglev $acset(loglev) $chan "StatCheat: $hand is repeating. Ignoring..."
  72. }
  73. return 1
  74. }
  75. }
  76. if {$acset(monologuepunish) != 0} {
  77. if {[stat:monologue $hand $chan]} {
  78. if {$acset(monologuepunish) == 2} {
  79. putloglev $acset(loglev) $chan "StatCheat: $hand is making a monologue since more than $acset(monologue) lines. Subtracting words instead of adding."
  80. incrstats $hand $chan words -[llength $rest]
  81. incrstats $hand $chan lines -1
  82. if {$type == "action"} {
  83. incrstats $hand $chan actions -1
  84. }
  85. } else {
  86. putloglev $acset(loglev) $chan "StatCheat: $hand is holding a monologue. Ignoring..."
  87. }
  88. return 1
  89. }
  90. }
  91. if {[string match "*\003*" $rest]} {
  92. if {$acset(colorpunish) == 2} {
  93. putloglev $acset(loglev) $chan "StatCheat: $hand is using colors. That's probably a script. Subtracting words instead of adding."
  94. incrstats $hand $chan words -[llength $rest]
  95. incrstats $hand $chan lines -1
  96. if {$type == "action"} {
  97. incrstats $hand $chan actions -1
  98. }
  99. } else {
  100. putloglev $acset(loglev) $chan "StatCheat: $hand is using colors. That's probably a script. Ignoring."
  101. }
  102. return 1
  103. }
  104. return 0
  105. }
  106. proc stat:repeated {hand chan text} {
  107. global statrepeat
  108. set idx ""
  109. lappend idx $hand
  110. lappend idx $chan
  111. if {![info exists statrepeat($idx)]} {
  112. set statrepeat($idx) ""
  113. }
  114. if {[lsearch -exact $statrepeat($idx) $text] > -1} {
  115. return 1
  116. } else {
  117. lappend statrepeat($idx) $text
  118. return 0
  119. }
  120. }
  121. proc stat:monologue {hand chan} {
  122. global statmonologue acset
  123. if {![info exists statmonologue($chan)]} {
  124. set statmonologue($chan) "foo 0"
  125. }
  126. set lasthand [lindex $statmonologue($chan) 0]
  127. set times [lindex $statmonologue($chan) 1]
  128. if {$lasthand != $hand} {
  129. set newdat ""
  130. lappend newdat $hand
  131. lappend newdat 1
  132. set statmonologue($chan) $newdat
  133. return 0
  134. } else {
  135. incr times
  136. set newdat ""
  137. lappend newdat $hand
  138. lappend newdat $times
  139. set statmonologue($chan) $newdat
  140. }
  141. if {$times >= $acset(monologue)} {
  142. return 1
  143. } else {
  144. return 0
  145. }
  146. }
  147. proc stat:resetstuff {} {
  148. global statrepeat statreset acset
  149. if {![info exists statreset]} {
  150. set statreset 0
  151. }
  152. if {[expr [unixtime] - $statreset] < $acset(tracktime)} {
  153. return
  154. }
  155. set statreset [unixtime]
  156. foreach item [array names statrepeat] {
  157. unset statrepeat($item)
  158. }
  159. catch "unbind ctcp - ACTION *ctcp:stat"
  160. catch "unbind pubm - * *pubm:stat"
  161. }
  162. putlog "AntiCheat v1.2.0 loaded."