18
18
db = sqlite3 .connect (app_dir + '/../database.db' )
19
19
#TODO Change this to 1800 for production
20
20
time_in_round = 1800
21
- min_time_between_clicks = 1
22
- spam_ban_time = 10
21
+ min_time_between_clicks = 2.0 # float seconds
22
+ spam_ban_time = 10.0 # float seconds
23
23
flag_index = 0
24
24
25
25
class BaseHandler (tornado .web .RequestHandler ):
@@ -51,9 +51,10 @@ def post(self):
51
51
raise tornado .web .HTTPError (403 )
52
52
53
53
# is the team being spammy?
54
+ user_id = self .get_current_user ()
54
55
now = time .time ()
55
56
cursor = db .cursor ()
56
- packaged = (team , ) #no idea why you have to do this
57
+ packaged = (user_id , ) #no idea why you have to do this
57
58
cursor .execute ("SELECT * from teams WHERE name=? LIMIT 1" , packaged )
58
59
row = cursor .fetchone ()
59
60
if not row :
@@ -65,15 +66,17 @@ def post(self):
65
66
66
67
if (spamming != 0 ):
67
68
if (since_last_click > spam_ban_time ):
68
- self .set_spamming (team , 0 )
69
+ self .set_spamming (user_id , 0 )
69
70
else :
71
+ self .set_click_time (user_id , now )
70
72
raise tornado .web .HTTPError (403 )
71
73
else :
72
74
if (since_last_click < min_time_between_clicks ):
73
- self .set_spamming (team , 1 )
75
+ self .set_click_time (user_id , now )
76
+ self .set_spamming (user_id , 1 )
74
77
raise tornado .web .HTTPError (403 )
75
78
76
- self .set_click_time (team , now )
79
+ self .set_click_time (user_id , now )
77
80
78
81
#check the captcha
79
82
captcha_id_int = int (captcha_id )
0 commit comments