From 6e13b8b73572f9c0ac9b5c683b98a475afbeab38 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 15 Aug 2018 13:13:17 +0200 Subject: yapf -rip on plugins --- plugins/quote.py | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'plugins/quote.py') diff --git a/plugins/quote.py b/plugins/quote.py index a5ffd193..b412cd9a 100644 --- a/plugins/quote.py +++ b/plugins/quote.py @@ -53,14 +53,18 @@ from poezio import tabs import logging log = logging.getLogger(__name__) + class Plugin(BasePlugin): def init(self): for _class in (tabs.MucTab, tabs.ConversationTab, tabs.PrivateTab): - self.api.add_tab_command(_class, 'quote', self.command_quote, - usage='', - help='Quote the message you typed if it exists.', - short='Quote a message.', - completion=self.completion_quote) + self.api.add_tab_command( + _class, + 'quote', + self.command_quote, + usage='', + help='Quote the message you typed if it exists.', + short='Quote a message.', + completion=self.completion_quote) def command_quote(self, args): args = common.shell_split(args) @@ -70,13 +74,20 @@ class Plugin(BasePlugin): return self.api.run_command('/help quote') message = self.find_message(message) if message: - before = self.config.get('before_quote', '') % {'nick': message.nickname or '', - 'time': message.str_time} - after = self.config.get('after_quote', '') % {'nick': message.nickname or '', - 'time': message.str_time} - self.core.insert_input_text('%(before)s%(quote)s%(after)s' % {'before': before.replace('\\n', '\n').replace('[SP]', ' '), - 'quote': clean_text(message.txt), - 'after': after.replace('\\n', '\n').replace('[SP]', ' ')}) + before = self.config.get('before_quote', '') % { + 'nick': message.nickname or '', + 'time': message.str_time + } + after = self.config.get('after_quote', '') % { + 'nick': message.nickname or '', + 'time': message.str_time + } + self.core.insert_input_text( + '%(before)s%(quote)s%(after)s' % { + 'before': before.replace('\\n', '\n').replace('[SP]', ' '), + 'quote': clean_text(message.txt), + 'after': after.replace('\\n', '\n').replace('[SP]', ' ') + }) else: self.api.information('No message found', 'Warning') @@ -92,6 +103,7 @@ class Plugin(BasePlugin): def completion_quote(self, the_input): def message_match(msg): return input_message.lower() in clean_text(msg.txt).lower() + messages = self.api.get_conversation_messages() if not messages: return @@ -102,5 +114,5 @@ class Plugin(BasePlugin): messages = list(filter(message_match, messages)) elif len(args) > 1: return False - return Completion(the_input.auto_completion, [clean_text(msg.txt) for msg in messages[::-1]], '') - + return Completion(the_input.auto_completion, + [clean_text(msg.txt) for msg in messages[::-1]], '') -- cgit v1.2.3