Okay I updated my script...
Nothing fancy. Just a starting point. You can use whatever database you prefer. I was using dictionaries and tuples to store the userid and timediff integers.
TODO: More state control.
NOTE: DO NOT FIRE THIS BITCH UP, THE LOGIC IS WRONG! I need to fix that once I stop being lazy.
import es;
import time;
# Set these values to your preference.
# floodthresh requests in timeforflood seconds...
floodthresh = 5;
timeforflood = 10;
cl = dict();
def es_client_command(event_var):
if(str(event_var['command']) == 'timeleft'):
userid = event_var['userid'];
if(not(cl.has_key(userid))):
tdiff = cl.get(userid)[1] - ct;
cl[userid] = (cl.get(userid)[0] + 1, ct);
if((cl.get(userid)[0] > floodthresh) and (tdiff <= timeforflood)):
es.tell(userid, "Banned for flooding timeleft (%i requests in % secs)." % (cl.get(userid)[0], tdiff));
es.server.queuecmd("banid %i %s" %(0, userid, ));
elif((cl.get(userid)[0] < floodthresh) and (tdiff > timeforflood)):