From a546bae3418a80a92ac1f4411ca0d546ee9672c5 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 21 Aug 2016 17:24:18 -0700 Subject: [PATCH] Irc: make throttle time configurable per server (defaults to 0.01s) --- classes.py | 3 ++- example-conf.yml | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/classes.py b/classes.py index d37e9b7..91f7204 100644 --- a/classes.py +++ b/classes.py @@ -172,7 +172,8 @@ class Irc(): if self.queue: # Only process if there's data. data = self.queue.popleft() self._send(data) - time.sleep(0.01) + throttle_time = self.serverdata.get('throttle_time', 0.01) + time.sleep(throttle_time) def connect(self): """ diff --git a/example-conf.yml b/example-conf.yml index a5adca7..a8cfc71 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -274,6 +274,11 @@ servers: # Autoconnect works like usual. autoconnect: 30 + # Message throttling: when set to a non-zero value, only one message will be sent every X + # seconds. If your bot is constantly running into Excess Flood errors, raising this to + # something like 0.5 or 1.0 should help. Defaults to 0.01 if not set. + throttle_time: 0.3 + # Plugins to load (omit the .py extension) plugins: # Commands plugin: Provides core commands such as logging in, shutting down