start: Add per-user rate limit

This commit is contained in:
nyuszika7h 2014-12-31 21:07:25 +01:00
parent 8b6393bf8e
commit 7d509e7c1d
2 changed files with 10 additions and 0 deletions

View File

@ -63,6 +63,7 @@ var.LAST_ADMINS = None
var.LAST_GSTATS = None
var.LAST_PSTATS = None
var.LAST_TIME = None
var.LAST_START = {}
var.USERS = {}
@ -5486,6 +5487,14 @@ def fstart(cli, nick, chan, rest):
start(cli, nick, chan)
def start(cli, nick, chan, forced = False):
if (var.LAST_START and nick in var.LAST_START and var.LAST_START[nick] +
timedelta(seconds=var.START_RATE_LIMIT) > datetime.now()):
cli.notice(nick, ("This command is rate-limited. Please wait a while "
"before using it again."))
return
var.LAST_START[nick] = datetime.now()
if chan != botconfig.CHANNEL:
return

View File

@ -13,6 +13,7 @@ ADMINS_RATE_LIMIT = 300
GSTATS_RATE_LIMIT = 0
PSTATS_RATE_LIMIT = 0
TIME_RATE_LIMIT = 10
START_RATE_LIMIT = 10 # (per-user)
SHOTS_MULTIPLIER = .12 # ceil(shots_multiplier * len_players) = bullets given
SHARPSHOOTER_MULTIPLIER = 0.06
MIN_PLAYERS = 4