adjust local_config from urlbot-mcabber/
This commit is contained in:
4
bot.py
4
bot.py
@@ -18,7 +18,7 @@ def message_handler(connect_object, message_node):
|
|||||||
if not type(msg_body) in [str, unicode]:
|
if not type(msg_body) in [str, unicode]:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if msg_body.startswith(conf('nick')):
|
if msg_body.startswith(conf('bot_user')):
|
||||||
connect_object.send(
|
connect_object.send(
|
||||||
xmpp.protocol.Message(
|
xmpp.protocol.Message(
|
||||||
to=conf('room'),
|
to=conf('room'),
|
||||||
@@ -41,7 +41,7 @@ client.connect()
|
|||||||
client.auth(jid.getNode(), conf('password'))
|
client.auth(jid.getNode(), conf('password'))
|
||||||
client.RegisterHandler('message', message_handler)
|
client.RegisterHandler('message', message_handler)
|
||||||
|
|
||||||
client.send(xmpp.Presence(to=(conf('room') + '/' + conf('nick'))))
|
client.send(xmpp.Presence(to=(conf('room') + '/' + conf('bot_user'))))
|
||||||
|
|
||||||
while (t + time.time()) < 30:
|
while (t + time.time()) < 30:
|
||||||
client.Process(1)
|
client.Process(1)
|
||||||
|
|||||||
@@ -1,18 +1,54 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import time, sys
|
||||||
|
|
||||||
|
def _logger(a, b): sys.stderr.write('logger: %s::%s\n' %(a, b))
|
||||||
|
try: logger
|
||||||
|
except NameError: logger = _logger
|
||||||
|
|
||||||
if '__main__' == __name__:
|
if '__main__' == __name__:
|
||||||
print '''don't try running this'''
|
print('''this is a config file, which is not meant to be executed''')
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
'jid': '',
|
'jid': 'FIXME',
|
||||||
'password': '',
|
'password': 'FIXME',
|
||||||
'room': '',
|
'room': 'FIXME',
|
||||||
'nick': '',
|
|
||||||
'nick': 'urlbot'
|
'src-url': 'FIXME',
|
||||||
|
|
||||||
|
'bot_user': 'native-urlbot',
|
||||||
|
'bot_owner': 'FIXME',
|
||||||
|
|
||||||
|
'hist_max_count': 5,
|
||||||
|
'hist_max_time': 10 * 60,
|
||||||
|
|
||||||
|
'uptime': -time.time(),
|
||||||
|
'request_counter': 0,
|
||||||
|
|
||||||
|
'path_event_files': 'event_files', # XXX obsolete
|
||||||
|
'path_cmdfifo': 'cmdfifo', # XXX obsolete
|
||||||
|
'persistent_storage': 'urlbot.persistent',
|
||||||
|
|
||||||
|
'url_blacklist': [
|
||||||
|
r'^.*heise\.de/[^/]+/meldung/.*$',
|
||||||
|
r'^.*wikipedia\.org/wiki/.*$'
|
||||||
|
],
|
||||||
|
|
||||||
|
# the "dice" feature will use more efficient random data (0) for given users
|
||||||
|
'enhanced-random-user': ( 'FIXME', 'FIXME' ),
|
||||||
|
|
||||||
|
'tea_steep_time': (3*60 + 40),
|
||||||
|
|
||||||
|
'image_preview': True
|
||||||
}
|
}
|
||||||
|
|
||||||
def conf(val):
|
def conf(val):
|
||||||
if val in config.keys():
|
if val in list(config.keys()):
|
||||||
return config[val]
|
return config[val]
|
||||||
|
logger('warn', 'conf(): unknown key ' + str(val))
|
||||||
|
return None
|
||||||
|
|
||||||
|
def set_conf(key, val):
|
||||||
|
config[key] = val
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user