1
0
Fork 0
forked from sch/KaikOut

Invoke KaikOut by its alias in a given group chat.

This commit is contained in:
Schimon Jehudah, Adv. 2024-09-16 15:37:51 +03:00
parent 7ca023011a
commit 561d36133f
3 changed files with 15 additions and 6 deletions

View file

@ -1,2 +1,2 @@
__version__ = '0.0.5'
__version_info__ = (0, 0, 5)
__version__ = '0.0.6'
__version_info__ = (0, 0, 6)

View file

@ -47,16 +47,20 @@ class XmppChat:
# Process commands.
message_type = message['type']
message_body = message['body']
jid = message['from']
jid_bare = jid.bare
if message_type == 'groupchat':
alias = message['mucnick']
room = message['mucroom']
alias_of_kaikout = XmppUtilities.get_self_alias(self, jid_bare)
if (message['mucnick'] == self.alias or
not XmppUtilities.is_moderator(self, room, alias) or
not message_body.startswith('%')):
not message_body.startswith(alias_of_kaikout)):
return
alias_of_kaikout_length = len(alias_of_kaikout) + 1
command = message_body[alias_of_kaikout_length:].lstrip()
elif message_type in ('chat', 'normal'):
jid = message['from']
jid_bare = jid.bare
command = message_body
jid_full = jid.full
room = self.sessions[jid_bare] if jid_bare in self.sessions else message_body
status_mode,status_text, message_response = None, None, None
@ -185,7 +189,6 @@ class XmppChat:
command_time_start = time.time()
command = message_body[1:] if message_type == 'groupchat' else message_body
command_lowercase = command.lower()
# if not self.settings[room]['enabled']:

View file

@ -10,6 +10,12 @@ logger = Logger(__name__)
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):
# try:
moderators = await XmppMuc.get_role_list(self, room, 'moderator')