plugin text command, XEP-0045, XEP-0048, XEP-0249: removed feedBackWrongContext which is no more usefull with new _contextValid method
This commit is contained in:
parent
b2bb3ed564
commit
9443b14c59
4 changed files with 31 additions and 73 deletions
|
|
@ -270,19 +270,6 @@ class TextCommands(object):
|
|||
|
||||
self.host.bridge.newMessage(unicode(mess_data["to"]), message, C.MESS_TYPE_INFO, unicode(_from), {}, profile=profile)
|
||||
|
||||
def feedBackWrongContext(self, command, types, mess_data, profile):
|
||||
"""Give a generic message to the user when a command has been used in a wrong context.
|
||||
|
||||
@param command (string): the command name (without the slash)
|
||||
@param types (string, list): the message types to which the command applies.
|
||||
@param mess_data (dict): original message data
|
||||
@param profile: %(doc_profile)s
|
||||
"""
|
||||
if not isinstance(types, str):
|
||||
types = _(' or ').join(types)
|
||||
feedback = _("/%(command)s command only applies on %(type)s messages. ") % {'command': command, 'type': types}
|
||||
self.host.plugins[C.TEXT_CMDS].feedBack(feedback + self.HELP_SUGGESTION, mess_data, profile)
|
||||
|
||||
def cmd_whois(self, mess_data, profile):
|
||||
"""show information on entity"""
|
||||
log.debug("Catched whois command")
|
||||
|
|
|
|||
|
|
@ -448,28 +448,24 @@ class XEP_0045(object):
|
|||
# Text commands #
|
||||
|
||||
def cmd_nick(self, mess_data, profile):
|
||||
"""change nickname"""
|
||||
log.debug("Catched nick command")
|
||||
|
||||
if mess_data['type'] != "groupchat":
|
||||
self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('nick', 'groupchat', mess_data, profile)
|
||||
return False
|
||||
"""change nickname
|
||||
|
||||
@command (group): new_nick
|
||||
- new_nick: new nick to use
|
||||
"""
|
||||
nick = mess_data["unparsed"].strip()
|
||||
room = mess_data["to"]
|
||||
|
||||
self.nick(room, nick, profile)
|
||||
if nick:
|
||||
room = mess_data["to"]
|
||||
self.nick(room, nick, profile)
|
||||
|
||||
return False
|
||||
|
||||
def cmd_join(self, mess_data, profile):
|
||||
"""join a new room (on the same service if full jid is not specified)"""
|
||||
log.debug("Catched join command")
|
||||
|
||||
if mess_data['type'] != "groupchat":
|
||||
self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('join', 'groupchat', mess_data, profile)
|
||||
return False
|
||||
"""join a new room
|
||||
|
||||
@command (group): JID
|
||||
- JID: room to join (on the same service if full jid is not specified)
|
||||
"""
|
||||
if mess_data["unparsed"].strip():
|
||||
room_jid = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host)
|
||||
nick = (self.getRoomNick(room_jid, profile) or
|
||||
|
|
@ -479,13 +475,11 @@ class XEP_0045(object):
|
|||
return False
|
||||
|
||||
def cmd_leave(self, mess_data, profile):
|
||||
"""quit a room"""
|
||||
log.debug("Catched leave command")
|
||||
|
||||
if mess_data['type'] != "groupchat":
|
||||
self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('leave', 'groupchat', mess_data, profile)
|
||||
return False
|
||||
"""quit a room
|
||||
|
||||
@command (group): [ROOM_JID]
|
||||
- ROOM_JID: jid of the room to live (current room if not specified)
|
||||
"""
|
||||
if mess_data["unparsed"].strip():
|
||||
room = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host)
|
||||
else:
|
||||
|
|
@ -496,21 +490,19 @@ class XEP_0045(object):
|
|||
return False
|
||||
|
||||
def cmd_part(self, mess_data, profile):
|
||||
"""just a synonym of /leave"""
|
||||
"""just a synonym of /leave
|
||||
|
||||
@command (group): [ROOM_JID]
|
||||
- ROOM_JID: jid of the room to live (current room if not specified)
|
||||
"""
|
||||
return self.cmd_leave(mess_data, profile)
|
||||
|
||||
def cmd_kick(self, mess_data, profile):
|
||||
"""kick a room member
|
||||
|
||||
@command (group): (nick)
|
||||
- nick: the nick of the person to kick
|
||||
@command (group): ROOM_NICK
|
||||
- ROOM_NICK: the nick of the person to kick
|
||||
"""
|
||||
log.debug("Catched kick command")
|
||||
|
||||
if mess_data['type'] != "groupchat":
|
||||
self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('kick', 'groupchat', mess_data, profile)
|
||||
return False
|
||||
|
||||
options = mess_data["unparsed"].strip().split()
|
||||
try:
|
||||
nick = options[0]
|
||||
|
|
@ -537,12 +529,6 @@ class XEP_0045(object):
|
|||
- JID: the JID of the entity to ban
|
||||
- reason: the reason why this entity is being banned
|
||||
"""
|
||||
log.debug("Catched ban command")
|
||||
|
||||
if mess_data['type'] != "groupchat":
|
||||
self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('ban', 'groupchat', mess_data, profile)
|
||||
return False
|
||||
|
||||
options = mess_data["unparsed"].strip().split()
|
||||
try:
|
||||
jid_s = options[0]
|
||||
|
|
@ -575,12 +561,6 @@ class XEP_0045(object):
|
|||
- none: reset entity privileges
|
||||
- outcast: ban entity
|
||||
"""
|
||||
log.debug("Catched affiliate command")
|
||||
|
||||
if mess_data['type'] != "groupchat":
|
||||
self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('affiliate', 'groupchat', mess_data, profile)
|
||||
return False
|
||||
|
||||
options = mess_data["unparsed"].strip().split()
|
||||
try:
|
||||
jid_s = options[0]
|
||||
|
|
@ -607,13 +587,11 @@ class XEP_0045(object):
|
|||
return d
|
||||
|
||||
def cmd_title(self, mess_data, profile):
|
||||
"""change room's subject"""
|
||||
log.debug("Catched title command")
|
||||
|
||||
if mess_data['type'] != "groupchat":
|
||||
self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('title', 'groupchat', mess_data, profile)
|
||||
return False
|
||||
"""change room's subject
|
||||
|
||||
@command (group): title
|
||||
- title: new room subject
|
||||
"""
|
||||
subject = mess_data["unparsed"].strip()
|
||||
|
||||
if subject:
|
||||
|
|
@ -623,7 +601,11 @@ class XEP_0045(object):
|
|||
return False
|
||||
|
||||
def cmd_topic(self, mess_data, profile):
|
||||
"""just a synonym of /title"""
|
||||
"""just a synonym of /title
|
||||
|
||||
@command (group): title
|
||||
- title: new room subject
|
||||
"""
|
||||
return self.cmd_title(mess_data, profile)
|
||||
|
||||
def _whois(self, whois_msg, mess_data, target_jid, profile):
|
||||
|
|
|
|||
|
|
@ -423,14 +423,9 @@ class XEP_0048(object):
|
|||
@command (group): [autojoin | remove]
|
||||
- autojoin: join room automatically on connection
|
||||
"""
|
||||
log.debug("Catched bookmark command")
|
||||
client = self.host.getClient(profile)
|
||||
txt_cmd = self.host.plugins[C.TEXT_CMDS]
|
||||
|
||||
if mess_data['type'] != "groupchat":
|
||||
self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('bookmark', 'groupchat', mess_data, profile)
|
||||
return False
|
||||
|
||||
options = mess_data["unparsed"].strip().split()
|
||||
if options and options[0] not in ('autojoin', 'remove'):
|
||||
txt_cmd.feedBack(_("Bad arguments"), mess_data, profile)
|
||||
|
|
|
|||
|
|
@ -171,12 +171,6 @@ class XEP_0249(object):
|
|||
@command (group): (JID)
|
||||
- JID: the JID of the person to invite
|
||||
"""
|
||||
log.debug("Catched invite command")
|
||||
|
||||
if mess_data['type'] != "groupchat":
|
||||
self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('invite', 'groupchat', mess_data, profile)
|
||||
return False
|
||||
|
||||
jid_s = mess_data["unparsed"].strip()
|
||||
try:
|
||||
assert(jid_s)
|
||||
|
|
|
|||
Loading…
Reference in a new issue