internal: make the other message handlers async
This commit is contained in:
parent
cf3d06fb0a
commit
b61db7d0bb
4 changed files with 11 additions and 11 deletions
|
@ -363,7 +363,7 @@ class HandlerCore:
|
|||
)
|
||||
self.core.tabs.append(conversation)
|
||||
else:
|
||||
conversation.handle_message(message)
|
||||
await conversation.handle_message(message)
|
||||
|
||||
if not own and 'private' in config.getstr('beep_on').split():
|
||||
if not config.get_by_tabname('disable_beep', conv_jid.bare):
|
||||
|
@ -547,7 +547,7 @@ class HandlerCore:
|
|||
self.core.tabs.append(tab)
|
||||
tab.parent_muc.privates.append(tab)
|
||||
else:
|
||||
tab.handle_message(message)
|
||||
await tab.handle_message(message)
|
||||
|
||||
if not sent and 'private' in config.getstr('beep_on').split():
|
||||
if not config.get_by_tabname('disable_beep', jid.full):
|
||||
|
|
|
@ -1020,7 +1020,7 @@ class OneToOneTab(ChatTab):
|
|||
'send a message along with the attention.')
|
||||
self.init_logs(initial=initial)
|
||||
|
||||
def init_logs(self, initial=None) -> None:
|
||||
def init_logs(self, initial: Optional[SMessage] = None) -> None:
|
||||
use_log = config.get_by_tabname('use_log', self.jid)
|
||||
mam_sync = config.get_by_tabname('mam_sync', self.jid)
|
||||
if use_log and mam_sync:
|
||||
|
@ -1031,19 +1031,19 @@ class OneToOneTab(ChatTab):
|
|||
if initial is not None:
|
||||
# If there is an initial message, throw it back into the
|
||||
# text buffer if it cannot be fetched from mam
|
||||
async def fallback_no_mam():
|
||||
async def fallback_no_mam() -> None:
|
||||
await mam_filler.done.wait()
|
||||
if mam_filler.result == 0:
|
||||
self.handle_message(initial)
|
||||
await self.handle_message(initial)
|
||||
|
||||
asyncio.create_task(fallback_no_mam())
|
||||
elif use_log and initial:
|
||||
self.handle_message(initial, display=False)
|
||||
asyncio.create_task(self.handle_message(initial, display=False))
|
||||
asyncio.create_task(
|
||||
LogLoader(logger, self, use_log).tab_open()
|
||||
)
|
||||
|
||||
def handle_message(self, msg: SMessage, display: bool = True):
|
||||
async def handle_message(self, msg: SMessage, display: bool = True):
|
||||
pass
|
||||
|
||||
def remote_user_color(self):
|
||||
|
|
|
@ -106,7 +106,7 @@ class ConversationTab(OneToOneTab):
|
|||
def completion(self):
|
||||
self.complete_commands(self.input)
|
||||
|
||||
def handle_message(self, message: SMessage, display: bool = True):
|
||||
async def handle_message(self, message: SMessage, display: bool = True):
|
||||
"""Handle a received message.
|
||||
|
||||
The message can come from us (carbon copy).
|
||||
|
@ -133,7 +133,7 @@ class ConversationTab(OneToOneTab):
|
|||
else:
|
||||
return
|
||||
|
||||
self.core.events.trigger('conversation_msg', message, self)
|
||||
await self.core.events.trigger_async('conversation_msg', message, self)
|
||||
|
||||
if not message['body']:
|
||||
return
|
||||
|
|
|
@ -142,7 +142,7 @@ class PrivateTab(OneToOneTab):
|
|||
and not self.input.get_text().startswith('//'))
|
||||
self.send_composing_chat_state(empty_after)
|
||||
|
||||
def handle_message(self, message: SMessage, display: bool = True):
|
||||
async def handle_message(self, message: SMessage, display: bool = True):
|
||||
sent = message['from'].bare == self.core.xmpp.boundjid.bare
|
||||
jid = message['to'] if sent else message['from']
|
||||
with_nick = jid.resource
|
||||
|
@ -156,7 +156,7 @@ class PrivateTab(OneToOneTab):
|
|||
)
|
||||
tmp_dir = get_image_cache()
|
||||
if not sent:
|
||||
self.core.events.trigger('private_msg', message, self)
|
||||
await self.core.events.trigger_async('private_msg', message, self)
|
||||
body = xhtml.get_body_from_message_stanza(
|
||||
message, use_xhtml=use_xhtml, extract_images_to=tmp_dir)
|
||||
if not body or not self:
|
||||
|
|
Loading…
Reference in a new issue