Commit 67c5bee9 authored by mathieui's avatar mathieui

Fix the quote plugin

(broken when refactoring messages)
parent 5c6b2ade
Pipeline #3690 passed with stages
in 4 minutes and 52 seconds
...@@ -45,8 +45,10 @@ Options ...@@ -45,8 +45,10 @@ Options
""" """
from poezio.core.structs import Completion from poezio.core.structs import Completion
from poezio.ui.types import Message
from poezio.plugin import BasePlugin from poezio.plugin import BasePlugin
from poezio.xhtml import clean_text from poezio.xhtml import clean_text
from poezio.theming import get_theme
from poezio import common from poezio import common
from poezio import tabs from poezio import tabs
...@@ -74,13 +76,14 @@ class Plugin(BasePlugin): ...@@ -74,13 +76,14 @@ class Plugin(BasePlugin):
return self.api.run_command('/help quote') return self.api.run_command('/help quote')
message = self.find_message(message) message = self.find_message(message)
if message: if message:
str_time = message.time.strftime(get_theme().SHORT_TIME_FORMAT)
before = self.config.get('before_quote', '') % { before = self.config.get('before_quote', '') % {
'nick': message.nickname or '', 'nick': message.nickname or '',
'time': message.str_time 'time': str_time,
} }
after = self.config.get('after_quote', '') % { after = self.config.get('after_quote', '') % {
'nick': message.nickname or '', 'nick': message.nickname or '',
'time': message.str_time 'time': str_time,
} }
self.core.insert_input_text( self.core.insert_input_text(
'%(before)s%(quote)s%(after)s' % { '%(before)s%(quote)s%(after)s' % {
...@@ -96,7 +99,7 @@ class Plugin(BasePlugin): ...@@ -96,7 +99,7 @@ class Plugin(BasePlugin):
if not messages: if not messages:
return None return None
for message in messages[::-1]: for message in messages[::-1]:
if clean_text(message.txt) == txt: if isinstance(message, Message) and clean_text(message.txt) == txt:
return message return message
return None return None
...@@ -114,5 +117,8 @@ class Plugin(BasePlugin): ...@@ -114,5 +117,8 @@ class Plugin(BasePlugin):
messages = list(filter(message_match, messages)) messages = list(filter(message_match, messages))
elif len(args) > 1: elif len(args) > 1:
return False return False
return Completion(the_input.auto_completion, return Completion(
[clean_text(msg.txt) for msg in messages[::-1]], '') the_input.auto_completion,
[clean_text(msg.txt) for msg in messages[::-1] if isinstance(msg, Message)],
''
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment