plugin debugging enabled

This commit is contained in:
urlbot
2014-09-28 22:44:42 +02:00
parent af9e195011
commit eba70a5ed0
2 changed files with 18 additions and 7 deletions

View File

@@ -41,6 +41,7 @@ def parse_mental_ill(args):
break break
if True == flag: if True == flag:
logger('plugin', 'sent mental illness reply')
return { return {
'msg': '''Multiple exclamation/question marks are a sure sign of mental disease, with %s as a living example.''' % args['reply_user'] 'msg': '''Multiple exclamation/question marks are a sure sign of mental disease, with %s as a living example.''' % args['reply_user']
} }
@@ -54,6 +55,7 @@ def parse_skynet(args):
} }
if 'skynet' in args['data'].lower(): if 'skynet' in args['data'].lower():
logger('plugin', 'sent skynet reply')
return { return {
'msg': '''I'm an independent bot and have nothing to do with other artificial intelligence systems!''' 'msg': '''I'm an independent bot and have nothing to do with other artificial intelligence systems!'''
} }
@@ -95,6 +97,7 @@ def command_command(args):
} }
if 'command' in args['data']: if 'command' in args['data']:
logger('plugin', 'sent command list')
return { return {
'msg': args['reply_user'] + ': known commands: ' + str(args['cmd_list']).strip('[]') 'msg': args['reply_user'] + ': known commands: ' + str(args['cmd_list']).strip('[]')
} }
@@ -124,17 +127,20 @@ def command_help(args):
return None return None
if None == cmd: if None == cmd:
logger('plugin', 'empty help request')
return { return {
'msg': args['reply_user'] + ': no command given' 'msg': args['reply_user'] + ': no command given'
} }
if not cmd in [p['name'] for p in plugins['command']]: if not cmd in [p['name'] for p in plugins['command']]:
logger('plugin', 'no help found for %s' % cmd)
return { return {
'msg': args['reply_user'] + ': no such command: %s' % cmd 'msg': args['reply_user'] + ': no such command: %s' % cmd
} }
for p in plugins['command']: for p in plugins['command']:
if cmd == p['name']: if cmd == p['name']:
logger('plugin', 'sent help for %s' % cmd)
return { return {
'msg': args['reply_user'] + ': help for %s: %s' %(cmd, p['desc']) 'msg': args['reply_user'] + ': help for %s: %s' %(cmd, p['desc'])
} }
@@ -150,6 +156,7 @@ def command_version(args):
} }
if 'version' in args['data']: if 'version' in args['data']:
logger('plugin', 'sent version string')
return { return {
'msg': args['reply_user'] + (''': I'm running ''' + VERSION) 'msg': args['reply_user'] + (''': I'm running ''' + VERSION)
} }
@@ -164,6 +171,7 @@ def command_unicode(args):
} }
if 'unikot' in args['data']: if 'unikot' in args['data']:
logger('plugin', 'sent some unicode')
return { return {
'msg': 'msg':
( (
@@ -183,6 +191,7 @@ def command_source(args):
} }
if 'source' in args['data']: if 'source' in args['data']:
logger('plugin', 'sent source URL')
return { return {
'msg': 'My source code can be found at %s' % conf('src-url') 'msg': 'My source code can be found at %s' % conf('src-url')
} }
@@ -199,8 +208,10 @@ def command_dice(args):
if 'dice' in args['data']: if 'dice' in args['data']:
if args['reply_user'] in conf('enhanced-random-user'): if args['reply_user'] in conf('enhanced-random-user'):
rnd = 0 # this might confuse users. good. rnd = 0 # this might confuse users. good.
logger('plugin', 'sent random (enhanced)')
else: else:
rnd = random.randint(1, 6) rnd = random.randint(1, 6)
logger('plugin', 'sent random')
dice_char = ['', '', '', '', '', '', ''] dice_char = ['', '', '', '', '', '', '']
return { return {
@@ -224,7 +235,7 @@ def command_uptime(args):
if 1 == u: plural_uptime = '' if 1 == u: plural_uptime = ''
if 1 == conf('request_counter'): plural_request = '' if 1 == conf('request_counter'): plural_request = ''
logger('info', 'sent statistics') logger('plugin', 'sent statistics')
return { return {
'msg': args['reply_user'] + (''': happily serving for %d second%s, %d request%s so far.''' %(u, plural_uptime, conf('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))
} }
@@ -242,13 +253,13 @@ def command_ping(args):
rnd = random.randint(0, 3) # 1:4 rnd = random.randint(0, 3) # 1:4
if 0 == rnd: if 0 == rnd:
msg = args['reply_user'] + ''': peng (You're dead now.)''' msg = args['reply_user'] + ''': peng (You're dead now.)'''
logger('info', 'sent pong (variant)') logger('plugin', 'sent pong (variant)')
elif 1 == rnd: elif 1 == rnd:
msg = args['reply_user'] + ''': I don't like you, leave me alone.''' msg = args['reply_user'] + ''': I don't like you, leave me alone.'''
logger('info', 'sent pong (dontlike)') logger('plugin', 'sent pong (dontlike)')
else: else:
msg = args['reply_user'] + ''': pong''' msg = args['reply_user'] + ''': pong'''
logger('info', 'sent pong') logger('plugin', 'sent pong')
return { return {
'msg': msg 'msg': msg
@@ -264,13 +275,13 @@ def command_info(args):
} }
if 'info' in args['data']: if 'info' in args['data']:
logger('info', 'sent long info') logger('plugin', 'sent long info')
return { return {
'msg': args['reply_user'] + (''': I'm a bot, my job is to extract <title> 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'))) 'msg': args['reply_user'] + (''': I'm a bot, my job is to extract <title> 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): def command_else(args):
logger('info', 'sent short info') logger('plugin', 'sent short info')
return { return {
'msg': args['reply_user'] + ''': I'm a bot (highlight me with 'info' for more information).''' 'msg': args['reply_user'] + ''': I'm a bot (highlight me with 'info' for more information).'''
} }

View File

@@ -215,5 +215,5 @@ if '__main__' == __name__:
time.sleep(delay) time.sleep(delay)
except KeyboardInterrupt: except KeyboardInterrupt:
print("") print('')
exit(130) exit(130)