mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
fix request counter
This commit is contained in:
@@ -13,7 +13,6 @@ hist_max_time = integer(default=10*60)
|
|||||||
|
|
||||||
# statistics
|
# statistics
|
||||||
uptime = integer(default=0)
|
uptime = integer(default=0)
|
||||||
request_counter = integer(default=0)
|
|
||||||
|
|
||||||
persistent_storage = string(default='urlbot.persistent')
|
persistent_storage = string(default='urlbot.persistent')
|
||||||
persistent_locked = boolean(default=false)
|
persistent_locked = boolean(default=false)
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
#!/usr/bin/python3
|
|
||||||
|
|
||||||
import time
|
|
||||||
|
|
||||||
if '__main__' == __name__:
|
|
||||||
print('''this is a config file, which is not meant to be executed''')
|
|
||||||
exit(-1)
|
|
||||||
|
|
||||||
config = {
|
|
||||||
'jid': 'FIXME',
|
|
||||||
'password': 'FIXME',
|
|
||||||
'rooms': ['FIXME'],
|
|
||||||
|
|
||||||
'src-url': 'http://aero2k.de/t/repos/urlbot-native.git',
|
|
||||||
|
|
||||||
'bot_user': 'native-urlbot',
|
|
||||||
'bot_owner': 'FIXME',
|
|
||||||
|
|
||||||
'hist_max_count': 5,
|
|
||||||
'hist_max_time': 10 * 60,
|
|
||||||
|
|
||||||
'uptime': -time.time(),
|
|
||||||
'request_counter': 0,
|
|
||||||
|
|
||||||
'persistent_storage': 'urlbot.persistent',
|
|
||||||
'persistent_locked': False,
|
|
||||||
|
|
||||||
'url_blacklist': [
|
|
||||||
r'^.*heise\.de/.*-[0-9]+\.html$',
|
|
||||||
r'^.*wikipedia\.org/wiki/.*$',
|
|
||||||
r'^.*blog\.fefe\.de/\?ts=[0-9a-f]+$',
|
|
||||||
r'^.*ibash\.de/zitat.*$',
|
|
||||||
r'^.*golem\.de/news/.*$'
|
|
||||||
r'^.*paste\.debian\.net/((hidden|plainh?)/)?[0-9a-f]+/?$',
|
|
||||||
r'^.*example\.(org|net|com).*$',
|
|
||||||
r'^.*sprunge\.us/.*$',
|
|
||||||
r'^.*ftp\...\.debian\.org.*$'
|
|
||||||
],
|
|
||||||
|
|
||||||
# the "dice" feature will use more efficient random data (0) for given users
|
|
||||||
'enhanced-random-user': ('FIXME', 'FIXME'),
|
|
||||||
|
|
||||||
# the "moin" feature will be "disabled" for given users
|
|
||||||
'moin-modified-user': (),
|
|
||||||
'moin-disabled-user': (),
|
|
||||||
|
|
||||||
'tea_steep_time': (3 * 60 + 40),
|
|
||||||
|
|
||||||
'image_preview': True,
|
|
||||||
'dsa_watcher_interval': 15 * 60
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def conf(val):
|
|
||||||
import logging
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
if val in list(config.keys()):
|
|
||||||
return config[val]
|
|
||||||
logger.warn('conf(): unknown key ' + str(val))
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def set_conf(key, val):
|
|
||||||
config[key] = val
|
|
||||||
return None
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# [main]
|
|
||||||
other_bots = string_list(default=list())
|
other_bots = string_list(default=list())
|
||||||
|
request_counter = integer(default=0)
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
[[info]]
|
[[info]]
|
||||||
|
|||||||
@@ -392,13 +392,13 @@ def command_uptime(argv, **args):
|
|||||||
|
|
||||||
if 1 == u:
|
if 1 == u:
|
||||||
plural_uptime = ''
|
plural_uptime = ''
|
||||||
if 1 == config.conf_get('request_counter'):
|
if 1 == config.runtimeconf_get('request_counter'):
|
||||||
plural_request = ''
|
plural_request = ''
|
||||||
|
|
||||||
log.info('sent statistics')
|
log.info('sent statistics')
|
||||||
return {
|
return {
|
||||||
'msg': args['reply_user'] + (''': happily serving for %d second%s, %d request%s so far.''' % (
|
'msg': args['reply_user'] + (''': happily serving for %d second%s, %d request%s so far.''' % (
|
||||||
u, plural_uptime, int(config.conf_get('request_counter')), plural_request))
|
u, plural_uptime, int(config.runtimeconf_get('request_counter')), plural_request))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,8 @@ class UrlBot(IdleBot):
|
|||||||
self.logger.warning("I'm muted! (status: %s)", self.show)
|
self.logger.warning("I'm muted! (status: %s)", self.show)
|
||||||
return
|
return
|
||||||
|
|
||||||
config.conf_set('request_counter', config.conf_get('request_counter') + 1)
|
config.runtimeconf_set('request_counter', config.runtimeconf_get('request_counter') + 1)
|
||||||
|
config.runtime_config_store.write()
|
||||||
|
|
||||||
if str is not type(message):
|
if str is not type(message):
|
||||||
message = '\n'.join(message)
|
message = '\n'.join(message)
|
||||||
|
|||||||
Reference in New Issue
Block a user