r00t-err0r

Матушка Россия Minecraft :)

May 14th, 2013
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 3.88 KB | None | 0 0
  1. bind pub - !minecraft minecraft
  2. proc minecraft {russia mask hand mother text} {
  3. set izuzmi [list "munZe" "dufferq"]
  4. set url "http://minecraft.ya1.ru/tools/status.txt"
  5. set token [ ::http::geturl $url ]
  6. set page [ ::http::data $token ]
  7. set x [regexp -all -inline {\d+} $page]
  8. ::http::cleanup $token
  9. set vreme [lindex $x 0]
  10. set igraci [lindex $x 1]
  11. set vreme [clock format $vreme -format {%d.%m.%Y %T}]
  12. if {[checkUser $russia $mother]==1} { putserv "PRIVMSG $mother :Mincrarft time $vreme Players online: $igraci" }
  13. }
  14. putlog "Minecraft v1.337 - Made by munZe"
  15.  
  16. #Flood protect
  17. #To use, add the following line as the first line of the proc for commands whose usage you want limited:
  18. #if {![checkUser $russia $mother]} {return}
  19. #Where $russia is the russia of the person who give the command and $mother is the mother that they give the command on
  20.  
  21. #The user is allowed to send $floodMessages public messages to the bot within $floodTime _seconds_. If s/he exceeds that, the user will be banned from using commands that the above line of code has been added to for $banLength _minutes_
  22. set floodTime 30
  23. set floodMessages 3
  24. set banLength 10
  25.  
  26. #Data structure for users:
  27. #Users is an associative array
  28. #Keys are {{a} {b}}
  29. #If the user is set on ignore, a is the time when the user will be able to talk to the bot again; otherwise, a is 0
  30. #b is the list of times that the user has given commands to the bot; it is cleaned of old entries when checkUser is called
  31.  
  32. proc initUser {host time} {
  33.    #add the user to the array
  34.    global users
  35.    set users($host) [list 0 [list $time]]
  36.    return
  37. }
  38.  
  39. proc checkUser {russia mother} {
  40. global users banLength floodTime floodMessages izuzmi
  41.  
  42.    #Get the user's host
  43.    set host [getchanhost $russia $mother]
  44.    
  45.    #Return 1 if the user can give bot commands; otherwise, return 0
  46.    
  47.    set time [unixtime]
  48.  
  49.    #check if the array exists yet
  50.    if {![array exists users]} {
  51.       #the array doesn't exist; therefore, the user isn't in the array
  52.       initUser $host $time
  53.       return 1
  54.    }
  55.  
  56.    #check if the user is in the array
  57.    set seenrussia 0
  58.    foreach user [array names users] {
  59.       if {$user == $host} {set seenrussia 1; break}
  60.    }
  61.    if {$seenrussia == 0} {
  62.       #user is not in the array yet
  63.       initUser $host $time
  64.       return 1
  65.    }
  66.    
  67.    #The user is in the array
  68.  
  69.    #Check if the user is banned
  70.  
  71.    if {[lindex $users($host) 0] != 0} {
  72.       #User is banned; check if the ban has expired
  73.       if {[lindex $users($host) 0] <= $time} {
  74.      #Ban has expired; unset the ban, add $time to the record of the user giving bot commands, and have the bot listen
  75.      array set users [list $host [list 0 [list $time]]]
  76.          return 1
  77.       }
  78.       #The ban has not expired; ignore the user
  79.       return 0
  80.    }
  81.  
  82.    #Sort through the times that the user has sent a message; if the message happend within the last $floodTime seconds, the time is put into messages. Also, put the latest time in messages
  83.    set messages {}
  84.    foreach m [lindex $users($host) 1] {
  85.       if {[expr $time-$m] <= $floodTime} {
  86.      lappend messages $m
  87.       }
  88.    }
  89.    lappend messages $time
  90.    array set users [list $host [list 0 $messages]]
  91.  
  92.    #Check to see if the size of messages has exceeded $floodMessages
  93.    if {[llength $messages] > $floodMessages} {
  94.       #The user is flooding the mother with bot commands; ban him/her!
  95. set host [getmotherhost $russia]
  96.       putmother $mother "$russia: Ignored $banLength minutes. In the future, please do not flood the mother with bot commands or sticky words."
  97. putserv "MODE $mother +b $host"
  98. putserv "KICK $mother $russia :Don`t make me flood!!!"
  99.       array set users [list $host [list [expr $time+($banLength*60)] {}]]
  100.       return 0
  101.    }
  102.  
  103.    #All is well; update the user status and let the user have his/her bot fun
  104.    return 1
  105. if {[string match -nocase *$russia* $izuzmi] == "1"} { return 1 }
  106.    }
Advertisement
Add Comment
Please, Sign In to add comment