1212
1313
1414def task_clear (loop ):
15- for uid , _bucket in buckets .copy ():
15+ global buckets
16+ for uid , _bucket in buckets .copy ().items ():
1617 if (time () - _bucket .timestamp ) > 600 :
1718 del buckets [uid ]
18- loop .call_later (600 , task_clear , loop )
19+ loop .call_later (10 , task_clear , loop )
1920
2021
2122@asyncio .coroutine
@@ -27,19 +28,15 @@ def init_tasks(loop, conn):
2728 return
2829
2930 logger .info ("[{}|sieve] Bot is starting ratelimiter cleanup task." .format (conn .name ))
30- loop .call_later (600 , task_clear , loop )
31+ loop .call_later (10 , task_clear , loop )
3132 ready = True
3233
3334
3435@asyncio .coroutine
3536@hook .sieve
3637def sieve_suite (bot , event , _hook ):
37- """
38- this function stands between your users and the commands they want to use. it decides if they can or not
39- :type bot: cloudbot.bot.CloudBot
40- :type event: cloudbot.event.Event
41- :type _hook: cloudbot.plugin.Hook
42- """
38+ global buckets
39+
4340 conn = event .conn
4441 # check ignore bots
4542 if event .irc_command == 'PRIVMSG' and event .nick .endswith ('bot' ) and _hook .ignore_bots :
@@ -78,8 +75,7 @@ def sieve_suite(bot, event, _hook):
7875
7976 # check command spam tokens
8077 if _hook .type == "command" :
81- # right now ratelimiting is per-channel, but this can be changed
82- uid = (event .chan , event .nick .lower ())
78+ uid = "!" .join ([conn .name , event .chan , event .nick ]).lower ()
8379
8480 tokens = conn .config .get ('ratelimit' , {}).get ('tokens' , 17.5 )
8581 restore_rate = conn .config .get ('ratelimit' , {}).get ('restore_rate' , 2.5 )
0 commit comments