/correct: send new-style LMC

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2020-04-05 02:58:02 +02:00
parent 747deb41e6
commit 8a25762e7b
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2
5 changed files with 14 additions and 5 deletions

View file

@ -770,7 +770,7 @@ class HandlerCore:
self.core.events.trigger('highlight', message, tab)
if message['from'].resource == tab.own_nick:
tab.last_sent_message = message
tab.set_last_sent_message(message, correct=replaced)
if tab is self.core.tabs.current_tab:
tab.text_win.refresh()
@ -862,7 +862,7 @@ class HandlerCore:
jid=message['from'],
typ=1)
if sent:
tab.last_sent_message = message
tab.set_last_sent_message(message, correct=replaced)
else:
tab.last_remote_message = datetime.now()

View file

@ -748,6 +748,15 @@ class ChatTab(Tab):
self.core.remove_timed_event(self.timed_event_not_paused)
self.timed_event_not_paused = None
def set_last_sent_message(self, msg, correct=False):
"""Ensure last_sent_message is set with the correct attributes"""
if correct:
# XXX: Is the copy needed. Is the object passed here reused
# afterwards? Who knows.
msg = copy.copy(msg)
msg['id'] = self.last_sent_message['id']
self.last_sent_message = msg
@command_args_parser.raw
def command_correct(self, line):
"""

View file

@ -139,7 +139,7 @@ class ConversationTab(OneToOneTab):
self.core.events.trigger('conversation_say_after', msg, self)
if not msg['body']:
return
self.last_sent_message = msg
self.set_last_sent_message(msg, correct=correct)
self.core.handler.on_normal_message(msg)
msg._add_receipt = True
msg.send()

View file

@ -1681,7 +1681,7 @@ class MucTab(ChatTab):
self.text_win.refresh()
self.input.refresh()
return
self.last_sent_message = msg
self.set_last_sent_message(msg, correct=correct)
msg.send()
self.chat_state = needed

View file

@ -177,7 +177,7 @@ class PrivateTab(OneToOneTab):
self.core.events.trigger('private_say_after', msg, self)
if not msg['body']:
return
self.last_sent_message = msg
self.set_last_sent_message(msg, correct=correct)
self.core.handler.on_groupchat_private_message(msg, sent=True)
msg._add_receipt = True
msg.send()