plugin text commands: added _feedback method to send an answer to user
This commit is contained in:
parent
53aefedcfa
commit
9612fe6f75
1 changed files with 11 additions and 9 deletions
|
|
@ -77,6 +77,15 @@ class TextCommands():
|
|||
return jid.JID(arg+service_jid)
|
||||
return jid.JID(u"%s@%s" % (arg, service_jid))
|
||||
|
||||
def _feedBack(self, message, mess_data, profile):
|
||||
"""Give a message back to the user"""
|
||||
if mess_data["type"] == 'groupchat':
|
||||
_from = mess_data["to"].userhostJID()
|
||||
else:
|
||||
_from = self.host.getJidNStream(profile)[0]
|
||||
|
||||
self.host.bridge.newMessage(unicode(mess_data["to"]), message, mess_data['type'], unicode(_from), {}, profile=profile)
|
||||
|
||||
def cmd_nick(self, mess_data, profile):
|
||||
"""change nickname"""
|
||||
debug("Catched nick command")
|
||||
|
|
@ -134,7 +143,7 @@ class TextCommands():
|
|||
return self.cmd_leave(mess_data, profile)
|
||||
|
||||
def cmd_title(self, mess_data, profile):
|
||||
"""Change room's subject"""
|
||||
"""change room's subject"""
|
||||
debug("Catched title command")
|
||||
|
||||
if mess_data['type'] != "groupchat":
|
||||
|
|
@ -165,14 +174,7 @@ class TextCommands():
|
|||
spaces = (longuest - len(command)) * ' '
|
||||
help_cmds.append(" /%s: %s %s" % (command[4:], spaces, help_str))
|
||||
|
||||
if mess_data["type"] == 'groupchat':
|
||||
_from = mess_data["to"].userhostJID()
|
||||
else:
|
||||
_from = self.host.getJidNStream(profile)[0]
|
||||
|
||||
help_mess = _(u"Text commands available:\n%s") % (u'\n'.join(help_cmds),)
|
||||
|
||||
self.host.bridge.newMessage(unicode(mess_data["to"]), help_mess, mess_data['type'], unicode(_from), {}, profile=profile)
|
||||
|
||||
self._feedBack(help_mess, mess_data, profile)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue