plugin XEP-0045: fix "reason" parsing for /ban and /kick text commands
This commit is contained in:
parent
8d9d911497
commit
26875b8552
1 changed files with 23 additions and 10 deletions
|
|
@ -720,12 +720,16 @@ class XEP_0045(object):
|
|||
self.text_cmds.feedBack(client, feedback, mess_data)
|
||||
return False
|
||||
|
||||
d = self.kick(client, nick, mess_data["to"], {} if len(options) == 1 else {'reason': options[1]})
|
||||
reason = ' '.join(options[1:]) if len(options) > 1 else None
|
||||
|
||||
d = self.kick(client, nick, mess_data["to"], {"reason": reason})
|
||||
|
||||
def cb(__):
|
||||
feedback_msg = _('You have kicked {}').format(nick)
|
||||
if len(options) > 1:
|
||||
feedback_msg += _(' for the following reason: {}').format(options[1])
|
||||
if reason is not None:
|
||||
feedback_msg += _(' for the following reason: {reason}').format(
|
||||
reason=reason
|
||||
)
|
||||
self.text_cmds.feedBack(client, feedback_msg, mess_data)
|
||||
return True
|
||||
d.addCallback(cb)
|
||||
|
|
@ -744,17 +748,24 @@ class XEP_0045(object):
|
|||
entity_jid = jid.JID(jid_s).userhostJID()
|
||||
assert(entity_jid.user)
|
||||
assert(entity_jid.host)
|
||||
except (RuntimeError, jid.InvalidFormat, AttributeError, IndexError, AssertionError):
|
||||
feedback = _("You must provide a valid JID to ban, like in '/ban contact@example.net'")
|
||||
except (RuntimeError, jid.InvalidFormat, AttributeError, IndexError,
|
||||
AssertionError):
|
||||
feedback = _(
|
||||
"You must provide a valid JID to ban, like in '/ban contact@example.net'"
|
||||
)
|
||||
self.text_cmds.feedBack(client, feedback, mess_data)
|
||||
return False
|
||||
|
||||
d = self.ban(client, entity_jid, mess_data["to"], {} if len(options) == 1 else {'reason': options[1]})
|
||||
reason = ' '.join(options[1:]) if len(options) > 1 else None
|
||||
|
||||
d = self.ban(client, entity_jid, mess_data["to"], {"reason": reason})
|
||||
|
||||
def cb(__):
|
||||
feedback_msg = _('You have banned {}').format(entity_jid)
|
||||
if len(options) > 1:
|
||||
feedback_msg += _(' for the following reason: {}').format(options[1])
|
||||
if reason is not None:
|
||||
feedback_msg += _(' for the following reason: {reason}').format(
|
||||
reason=reason
|
||||
)
|
||||
self.text_cmds.feedBack(client, feedback_msg, mess_data)
|
||||
return True
|
||||
d.addCallback(cb)
|
||||
|
|
@ -791,7 +802,8 @@ class XEP_0045(object):
|
|||
d = self.affiliate(client, entity_jid, mess_data["to"], {'affiliation': affiliation})
|
||||
|
||||
def cb(__):
|
||||
feedback_msg = _('New affiliation for %(entity)s: %(affiliation)s').format(entity=entity_jid, affiliation=affiliation)
|
||||
feedback_msg = _('New affiliation for {entity}: {affiliation}').format(
|
||||
entity=entity_jid, affiliation=affiliation)
|
||||
self.text_cmds.feedBack(client, feedback_msg, mess_data)
|
||||
return True
|
||||
d.addCallback(cb)
|
||||
|
|
@ -837,7 +849,8 @@ class XEP_0045(object):
|
|||
elif client.muc_service is not None:
|
||||
service = client.muc_service
|
||||
else:
|
||||
msg = D_("No known default MUC service".format(unparsed))
|
||||
msg = D_("No known default MUC service {unparsed}").format(
|
||||
unparsed=unparsed)
|
||||
self.text_cmds.feedBack(client, msg, mess_data)
|
||||
return False
|
||||
except jid.InvalidFormat:
|
||||
|
|
|
|||
Loading…
Reference in a new issue