forked from sch/Slixfeed
Invoke Slixfeed by its alias in a given group chat.
This commit is contained in:
parent
e63a5e4a74
commit
2a9d2657b1
3 changed files with 13 additions and 4 deletions
|
@ -1,2 +1,2 @@
|
|||
__version__ = '0.1.98'
|
||||
__version_info__ = (0, 1, 98)
|
||||
__version__ = '0.1.99'
|
||||
__version_info__ = (0, 1, 99)
|
||||
|
|
|
@ -102,8 +102,9 @@ class XmppChat:
|
|||
# nick = message['from'][message['from'].index('/')+1:]
|
||||
# nick = str(message['from'])
|
||||
# nick = nick[nick.index('/')+1:]
|
||||
alias_of_slixfeed = XmppUtilities.get_self_alias(self, jid_bare)
|
||||
if (alias == self.alias or
|
||||
not message['body'].startswith('!')):
|
||||
not message['body'].startswith(alias_of_slixfeed)):
|
||||
return
|
||||
# token = await initdb(
|
||||
# jid_bare,
|
||||
|
@ -156,7 +157,9 @@ class XmppChat:
|
|||
else:
|
||||
omemo_decrypted = None
|
||||
|
||||
if message_type == 'groupchat': command = command[1:]
|
||||
# Adding one to the length because of assumption that a comma or a dot is added
|
||||
alias_of_slixfeed_length = len(alias_of_slixfeed) + 1
|
||||
if message_type == 'groupchat': command = (command[alias_of_slixfeed_length:]).lstrip()
|
||||
if isinstance(command, Message): command = command['body']
|
||||
|
||||
command_lowercase = command.lower()
|
||||
|
|
|
@ -11,6 +11,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 get_chat_type(self, jid):
|
||||
"""
|
||||
Check chat (i.e. JID) type.
|
||||
|
|
Loading…
Reference in a new issue