forked from sch/KaikOut
Invoke KaikOut by its alias in a given group chat.
This commit is contained in:
parent
7ca023011a
commit
561d36133f
3 changed files with 15 additions and 6 deletions
|
@ -1,2 +1,2 @@
|
||||||
__version__ = '0.0.5'
|
__version__ = '0.0.6'
|
||||||
__version_info__ = (0, 0, 5)
|
__version_info__ = (0, 0, 6)
|
||||||
|
|
|
@ -47,16 +47,20 @@ class XmppChat:
|
||||||
# Process commands.
|
# Process commands.
|
||||||
message_type = message['type']
|
message_type = message['type']
|
||||||
message_body = message['body']
|
message_body = message['body']
|
||||||
|
jid = message['from']
|
||||||
|
jid_bare = jid.bare
|
||||||
if message_type == 'groupchat':
|
if message_type == 'groupchat':
|
||||||
alias = message['mucnick']
|
alias = message['mucnick']
|
||||||
room = message['mucroom']
|
room = message['mucroom']
|
||||||
|
alias_of_kaikout = XmppUtilities.get_self_alias(self, jid_bare)
|
||||||
if (message['mucnick'] == self.alias or
|
if (message['mucnick'] == self.alias or
|
||||||
not XmppUtilities.is_moderator(self, room, alias) or
|
not XmppUtilities.is_moderator(self, room, alias) or
|
||||||
not message_body.startswith('%')):
|
not message_body.startswith(alias_of_kaikout)):
|
||||||
return
|
return
|
||||||
|
alias_of_kaikout_length = len(alias_of_kaikout) + 1
|
||||||
|
command = message_body[alias_of_kaikout_length:].lstrip()
|
||||||
elif message_type in ('chat', 'normal'):
|
elif message_type in ('chat', 'normal'):
|
||||||
jid = message['from']
|
command = message_body
|
||||||
jid_bare = jid.bare
|
|
||||||
jid_full = jid.full
|
jid_full = jid.full
|
||||||
room = self.sessions[jid_bare] if jid_bare in self.sessions else message_body
|
room = self.sessions[jid_bare] if jid_bare in self.sessions else message_body
|
||||||
status_mode,status_text, message_response = None, None, None
|
status_mode,status_text, message_response = None, None, None
|
||||||
|
@ -185,7 +189,6 @@ class XmppChat:
|
||||||
|
|
||||||
command_time_start = time.time()
|
command_time_start = time.time()
|
||||||
|
|
||||||
command = message_body[1:] if message_type == 'groupchat' else message_body
|
|
||||||
command_lowercase = command.lower()
|
command_lowercase = command.lower()
|
||||||
|
|
||||||
# if not self.settings[room]['enabled']:
|
# if not self.settings[room]['enabled']:
|
||||||
|
|
|
@ -10,6 +10,12 @@ logger = Logger(__name__)
|
||||||
|
|
||||||
class XmppUtilities:
|
class XmppUtilities:
|
||||||
|
|
||||||
|
def get_self_alias(self, room):
|
||||||
|
"""Get self alias of a given group chat"""
|
||||||
|
jid_full = self.plugin['xep_0045'].get_our_jid_in_room(room)
|
||||||
|
alias = jid_full.split('/')[1]
|
||||||
|
return alias
|
||||||
|
|
||||||
async def is_jid_of_moderators(self, room, jid_full):
|
async def is_jid_of_moderators(self, room, jid_full):
|
||||||
# try:
|
# try:
|
||||||
moderators = await XmppMuc.get_role_list(self, room, 'moderator')
|
moderators = await XmppMuc.get_role_list(self, room, 'moderator')
|
||||||
|
|
Loading…
Reference in a new issue