bugfixes, can omit username in PMs now

This commit is contained in:
Thorsten
2016-01-01 20:54:19 +01:00
parent 5fe0db35c0
commit 4c90012111
2 changed files with 8 additions and 4 deletions

View File

@@ -136,7 +136,7 @@ def command_unicode(argv, **args):
@pluginfunction('dice', 'rolls a dice, optional N times', ptypes_COMMAND, ratelimit_class=RATE_INTERACTIVE) @pluginfunction('dice', 'rolls a dice, optional N times', ptypes_COMMAND, ratelimit_class=RATE_INTERACTIVE)
def command_dice(argv, **args): def command_dice(argv, **args):
try: try:
count = 1 if argv else int(argv[0]) count = 1 if not argv else int(argv[0])
except ValueError as e: except ValueError as e:
return { return {
'msg': '%s: dice: error when parsing int(%s): %s' % ( 'msg': '%s: dice: error when parsing int(%s): %s' % (

View File

@@ -247,11 +247,15 @@ class UrlBot(IdleBot):
data = msg_obj['body'] data = msg_obj['body']
words = data.split() words = data.split()
# prepend the bot nick so we have the same syntax as in muc
if msg_obj['type'] == 'chat' and words and self.nick not in words[0]:
words = [self.nick] + words
if len(words) < 2: # need at least two words if len(words) < 2: # need at least two words
return None return None
# don't reply if beginning of the text matches bot_nickname # only reply if beginning of the text matches bot_nickname or it's a private session.
if not data.startswith(config.conf_get('bot_nickname')): if msg_obj['type'] == 'groupchat' and not data.startswith(config.conf_get('bot_nickname')):
return None return None
if 'hangup' in data: if 'hangup' in data:
@@ -275,7 +279,7 @@ class UrlBot(IdleBot):
parser_list=[pl.plugin_name for pl in plugin_storage[ptypes_PARSE]], parser_list=[pl.plugin_name for pl in plugin_storage[ptypes_PARSE]],
reply_user=reply_user, reply_user=reply_user,
msg_obj=msg_obj, msg_obj=msg_obj,
argv=words[2:] argv=words[2:] if len(words) > 1 else []
) )
if ret: if ret: