Added additional limits for "gamestats" parameters.

Added check to make sure the parameter is an integer between 4 and
var.MAX_PLAYERS.
This commit is contained in:
Yizhe Shen 2014-02-10 23:39:42 -05:00
parent 977112826f
commit 79b870499b

View File

@ -2891,13 +2891,14 @@ def game_stats(cli, nick, chan, rest):
cli.msg(chan, var.get_game_totals()) cli.msg(chan, var.get_game_totals())
return return
# Check that size is an integer. # Check for invalid input
if not rest.isdigit(): rest = rest.strip()
cli.notice(nick, "Please enter an integer.") if not rest.isdigit() or int(rest) > var.MAX_PLAYERS or int(rest) < 4:
cli.notice(nick, "Please enter an integer between {0} and {1}.".format(4, var.MAX_PLAYERS))
return return
# Attempt to find game stats for the given game size. # Attempt to find game stats for the given game size.
size = int(rest.strip()) size = int(rest)
msg = var.get_game_stats(size) msg = var.get_game_stats(size)
if msg == "": if msg == "":
cli.msg(chan, "No stats for \u0002{0}\u0002 player games.".format(size)) cli.msg(chan, "No stats for \u0002{0}\u0002 player games.".format(size))