diff --git a/local_config.py.skel b/local_config.py.skel
index df19565..4a3edff 100644
--- a/local_config.py.skel
+++ b/local_config.py.skel
@@ -10,6 +10,9 @@ config['src-url'] = 'FIXME'
config['bot_user'] = 'urlbot'
config['bot_owner'] = 'FIXME'
+config['hist_max_count'] = 5
+config['hist_max_time'] = 10 * 60
+
# the "dice" feature will use more efficient random data (0) for given users
config['enhanced-random-user'] = ( 'FIXME', 'FIXME' )
diff --git a/plugins.py b/plugins.py
index 16a68ec..349b364 100644
--- a/plugins.py
+++ b/plugins.py
@@ -217,7 +217,7 @@ def command_info(args):
if 'info' in args['data']:
logger('info', 'sent long info')
return {
- 'msg': args['reply_user'] + (''': I'm a bot, my job is to extract
tags from posted URLs. In case I'm annoying or for further questions, please talk to my master %s. I'm rate limited and shouldn't post more than %d messages per %d seconds. To make me exit immediately, highlight me with 'hangup' in the message (emergency only, please). For other commands, highlight me with 'command'.''' %(conf('bot_owner'), hist_max_count, hist_max_time))
+ 'msg': args['reply_user'] + (''': I'm a bot, my job is to extract tags from posted URLs. In case I'm annoying or for further questions, please talk to my master %s. I'm rate limited and shouldn't post more than %d messages per %d seconds. To make me exit immediately, highlight me with 'hangup' in the message (emergency only, please). For other commands, highlight me with 'command'.''' %(conf('bot_owner'), conf('hist_max_count'), conf('hist_max_time')))
}
def command_else(args):
diff --git a/urlbot.py b/urlbot.py
index 69d95cc..3a1c579 100755
--- a/urlbot.py
+++ b/urlbot.py
@@ -14,8 +14,6 @@ event_files_dir = os.path.join(basedir, 'event_files')
fifo_path = os.path.join(basedir, 'cmdfifo')
# rate limiting to 5 messages per 10 minutes
-hist_max_count = 5
-hist_max_time = 10 * 60
hist_ts = []
hist_flag = True
uptime = -time.time()
@@ -135,19 +133,19 @@ def ratelimit_touch(ignored=None): # FIXME: separate counters
now = time.time()
hist_ts.append(now)
- if hist_max_count < len(hist_ts):
+ if conf('hist_max_count') < len(hist_ts):
hist_ts.pop(0)
def ratelimit_exceeded(ignored=None): # FIXME: separate counters
global hist_flag
- if hist_max_count < len(hist_ts):
+ if conf('hist_max_count') < len(hist_ts):
first = hist_ts.pop(0)
- if (now - first) < hist_max_time:
+ if (now - first) < conf('hist_max_time'):
if hist_flag:
hist_flag = False
- chat_write('(rate limited to %d messages in %d seconds, try again at %s)' %(hist_max_count, hist_max_time, time.strftime('%T %Z', time.localtime(hist_ts[0] + hist_max_time))))
+ chat_write('(rate limited to %d messages in %d seconds, try again at %s)' %(conf('hist_max_count'), conf('hist_max_time'), time.strftime('%T %Z', time.localtime(hist_ts[0] + conf('hist_max_time')))))
logger('warn', 'rate limiting exceeded: ' + pickle.dumps(hist_ts))
return True