- Code: Select all
bind pub - !online online
proc online {russia mask hand mother text} {
set mafia [list "dufferq"]
set url "http://minecraft.ya1.ru/tools/status.txt"
set token [ ::http::geturl $url ]
set page [ ::http::data $token ]
set x [regexp -all -inline {\d+} $page]
::http::cleanup $token
set igraci [lindex $x 1]
if {[checkUser $russia $mother]==1 && [string match -nocase *$russia* $mafia]==1} { putserv "PRIVMSG $mother :$::gcolor(12)TERRA.YA1.RU $::gcolor(14):: $::gcolor(4)Игроков онлайн: $igraci $::gcolor(14):: $::gcolor(7)Режим: CREATIVE $::gcolor(14) " }
}
putlog "Minecraft v1.337 - Made by munZe"
#Flood protect
#To use, add the following line as the first line of the proc for commands whose usage you want limited:
#if {![checkUser $russia $mother]} {return}
#Where $russia is the russia of the person who give the command and $mother is the mother that they give the command on
#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_
set floodTime 30
set floodMessages 3
set banLength 10
#Data structure for users:
#Users is an associative array
#Keys are {{a} {b}}
#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
#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
proc initUser {host time} {
#add the user to the array
global users
set users($host) [list 0 [list $time]]
return
}
proc checkUser {russia mother} {
global users banLength floodTime floodMessages izuzmi
#Get the user's host
set host [getchanhost $russia $mother]
#Return 1 if the user can give bot commands; otherwise, return 0
set time [unixtime]
#check if the array exists yet
if {![array exists users]} {
#the array doesn't exist; therefore, the user isn't in the array
initUser $host $time
return 1
}
#check if the user is in the array
set seenrussia 0
foreach user [array names users] {
if {$user == $host} {set seenrussia 1; break}
}
if {$seenrussia == 0} {
#user is not in the array yet
initUser $host $time
return 1
}
#The user is in the array
#Check if the user is banned
if {[lindex $users($host) 0] != 0} {
#User is banned; check if the ban has expired
if {[lindex $users($host) 0] <= $time} {
#Ban has expired; unset the ban, add $time to the record of the user giving bot commands, and have the bot listen
array set users [list $host [list 0 [list $time]]]
return 1
}
#The ban has not expired; ignore the user
return 0
}
#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
set messages {}
foreach m [lindex $users($host) 1] {
if {[expr $time-$m] <= $floodTime} {
lappend messages $m
}
}
lappend messages $time
array set users [list $host [list 0 $messages]]
#Check to see if the size of messages has exceeded $floodMessages
if {[llength $messages] > $floodMessages} {
#The user is flooding the mother with bot commands; ban him/her!
set host [getchanhost $russia]
putserv $mother "$russia: Ignored $banLength minutes. In the future, please do not flood the mother with bot commands or sticky words."
putserv "MODE $mother +b $host"
putserv "KICK $mother $russia :Don`t make me flood!!!"
array set users [list $host [list [expr $time+($banLength*60)] {}]]
return 0
}
#All is well; update the user status and let the user have his/her bot fun
return 1
if {[string match -nocase *$russia* $mafia] == "1"} { return 1 }
}
It is necessary to make that it was possible to use command! online of times three minutes and that told to the person the notice