strip : from user in record {user}
This commit is contained in:
@@ -205,6 +205,14 @@ def pluginfunction(name, desc, plugin_type, ratelimit_class=RATE_GLOBAL, enabled
|
||||
return decorate
|
||||
|
||||
|
||||
def get_nick_from_object(message_obj):
|
||||
"""
|
||||
not quite correct yet, also the private property access isn't nice.
|
||||
"""
|
||||
nick = message_obj['mucnick'] or message_obj['from']._jid[2]
|
||||
return nick
|
||||
|
||||
|
||||
ptypes_PARSE = 'parser'
|
||||
ptypes_COMMAND = 'command'
|
||||
ptypes = [ptypes_PARSE, ptypes_COMMAND]
|
||||
|
||||
@@ -15,7 +15,9 @@ from common import (
|
||||
VERSION, RATE_FUN, RATE_GLOBAL, RATE_INTERACTIVE, RATE_NO_LIMIT,
|
||||
giphy, pluginfunction,
|
||||
ptypes_COMMAND,
|
||||
RATE_NO_SILENCE)
|
||||
RATE_NO_SILENCE,
|
||||
get_nick_from_object
|
||||
)
|
||||
from string_constants import cakes, excuses, moin_strings_hi, moin_strings_bye, languages
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -485,11 +487,11 @@ def command_record(argv, **args):
|
||||
'msg': '%s: usage: record {user} {some message}' % args['reply_user']
|
||||
}
|
||||
|
||||
target_user = argv[0].lower()
|
||||
target_user = argv[0].lower().strip(':')
|
||||
message = '{} ({}): '.format(args['reply_user'], time.strftime('%Y-%m-%d %H:%M'))
|
||||
if argv[1] == "previous":
|
||||
prev_message_obj = args['stack'][-1]
|
||||
message += '[{}]: '.format(prev_message_obj['mucnick'] or prev_message_obj['from']._jid[2])
|
||||
message += '[{}]: '.format(get_nick_from_object(prev_message_obj))
|
||||
message += prev_message_obj['body']
|
||||
else:
|
||||
message += ' '.join(argv[1:])
|
||||
|
||||
13
urlbot.py
13
urlbot.py
@@ -17,7 +17,7 @@ from common import (
|
||||
RATE_CHAT,
|
||||
RATE_EVENT,
|
||||
rate_limit,
|
||||
)
|
||||
get_nick_from_object)
|
||||
from config import runtimeconf_set
|
||||
from idlebot import IdleBot, start
|
||||
from plugins import (
|
||||
@@ -174,9 +174,10 @@ class UrlBot(IdleBot):
|
||||
msg_obj['type'] = 'chat'
|
||||
self.send_reply("You're flagged as bot, please write {}: remove-from-botlist "
|
||||
"{} if you're not a bot.".format(
|
||||
config.conf_get('bot_nickname'), msg_obj['from']._jid[2]
|
||||
config.conf_get('bot_nickname'),
|
||||
get_nick_from_object(msg_obj)
|
||||
), msg_obj)
|
||||
self.logger.debug("not talking to the other bot named {}".format(msg_obj['from']._jid[2]))
|
||||
self.logger.debug("not talking to the other bot named {}".format(get_nick_from_object(msg_obj)))
|
||||
return False
|
||||
self.send_message(
|
||||
mto=msg_obj['from'].bare,
|
||||
@@ -233,7 +234,7 @@ class UrlBot(IdleBot):
|
||||
|
||||
if (msg_obj['body'].startswith(config.conf_get('bot_nickname')) and not any(
|
||||
[reacted_on_command, reacted_on_parse]) and rate_limit(RATE_GLOBAL)):
|
||||
ret = else_command({'reply_user': msg_obj['from']._jid[2]})
|
||||
ret = else_command({'reply_user': get_nick_from_object(msg_obj)})
|
||||
if ret:
|
||||
if 'msg' in ret:
|
||||
self.send_reply(ret['msg'], msg_obj)
|
||||
@@ -273,7 +274,7 @@ class UrlBot(IdleBot):
|
||||
self.hangup()
|
||||
sys.exit(1)
|
||||
|
||||
reply_user = msg_obj['mucnick'] or msg_obj['from']._jid[2]
|
||||
reply_user = get_nick_from_object(msg_obj)
|
||||
|
||||
# TODO: check how several commands/plugins
|
||||
# in a single message behave (also with rate limiting)
|
||||
@@ -306,7 +307,7 @@ class UrlBot(IdleBot):
|
||||
:return:
|
||||
"""
|
||||
data = msg_obj['body']
|
||||
reply_user = msg_obj['mucnick'] or msg_obj['from']._jid[2]
|
||||
reply_user = get_nick_from_object(msg_obj)
|
||||
reacted = False
|
||||
|
||||
for plugin in plugin_storage[ptypes_PARSE]:
|
||||
|
||||
Reference in New Issue
Block a user