scope fixes; put request_counter to conf()
This commit is contained in:
@@ -16,6 +16,8 @@ config['hist_max_count'] = 5
|
|||||||
config['hist_max_time'] = 10 * 60
|
config['hist_max_time'] = 10 * 60
|
||||||
|
|
||||||
config['uptime'] = -time.time()
|
config['uptime'] = -time.time()
|
||||||
|
config['request_counter'] = 0
|
||||||
|
|
||||||
|
|
||||||
# the "dice" feature will use more efficient random data (0) for given users
|
# the "dice" feature will use more efficient random data (0) for given users
|
||||||
config['enhanced-random-user'] = ( 'FIXME', 'FIXME' )
|
config['enhanced-random-user'] = ( 'FIXME', 'FIXME' )
|
||||||
@@ -24,3 +26,7 @@ def conf(val):
|
|||||||
if val in config.keys():
|
if val in config.keys():
|
||||||
return config[val]
|
return config[val]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def set_conf(key, val):
|
||||||
|
config[key] = val
|
||||||
|
return None
|
||||||
|
|||||||
@@ -175,11 +175,11 @@ def command_uptime(args):
|
|||||||
plural_request = 's'
|
plural_request = 's'
|
||||||
|
|
||||||
if 1 == u: plural_uptime = ''
|
if 1 == u: plural_uptime = ''
|
||||||
if 1 == request_counter: plural_request = ''
|
if 1 == conf('request_counter'): plural_request = ''
|
||||||
|
|
||||||
logger('info', 'sent statistics')
|
logger('info', 'sent statistics')
|
||||||
return {
|
return {
|
||||||
'msg': args['reply_user'] + (''': happily serving for %d second%s, %d request%s so far.''' %(u, plural_uptime, request_counter, plural_request))
|
'msg': args['reply_user'] + (''': happily serving for %d second%s, %d request%s so far.''' %(u, plural_uptime, conf('request_counter'), plural_request))
|
||||||
}
|
}
|
||||||
|
|
||||||
def command_ping(args):
|
def command_ping(args):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import sys, os, re, time, urllib, pickle, random, HTMLParser, stat
|
import sys, os, re, time, urllib, pickle, random, HTMLParser, stat
|
||||||
from local_config import conf
|
from local_config import conf, set_conf
|
||||||
|
|
||||||
BUFSIZ = 8192
|
BUFSIZ = 8192
|
||||||
delay = 0.100 # seconds
|
delay = 0.100 # seconds
|
||||||
@@ -16,7 +16,6 @@ fifo_path = os.path.join(basedir, 'cmdfifo')
|
|||||||
# rate limiting to 5 messages per 10 minutes
|
# rate limiting to 5 messages per 10 minutes
|
||||||
hist_ts = []
|
hist_ts = []
|
||||||
hist_flag = True
|
hist_flag = True
|
||||||
request_counter = 0
|
|
||||||
|
|
||||||
parser = None
|
parser = None
|
||||||
|
|
||||||
@@ -106,8 +105,7 @@ def extract_title(url):
|
|||||||
return (-1, 'error')
|
return (-1, 'error')
|
||||||
|
|
||||||
def chat_write(message, prefix='/say '):
|
def chat_write(message, prefix='/say '):
|
||||||
global request_counter
|
set_conf('request_counter', conf('request_counter') + 1)
|
||||||
request_counter += 1
|
|
||||||
|
|
||||||
if debug_enabled():
|
if debug_enabled():
|
||||||
print message
|
print message
|
||||||
@@ -243,8 +241,6 @@ plugins.ratelimit_touch = ratelimit_touch
|
|||||||
plugins.random = random
|
plugins.random = random
|
||||||
plugins.time = time
|
plugins.time = time
|
||||||
|
|
||||||
plugins.request_counter = request_counter
|
|
||||||
|
|
||||||
plugins.register_all()
|
plugins.register_all()
|
||||||
|
|
||||||
if '__main__' == __name__:
|
if '__main__' == __name__:
|
||||||
|
|||||||
Reference in New Issue
Block a user