diff options
author | mathieui <mathieui@mathieui.net> | 2013-03-08 22:53:35 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2013-03-08 22:53:35 +0100 |
commit | 9885203c6799c121f5bc8a733dc1937fe8c1b4d6 (patch) | |
tree | 4190635a7c9c78d2dce1a4c8357ccb887f12b8af /plugins/quote.py | |
parent | dbde08a5267cf003d8a4a9c16f5b18275e9a4bd1 (diff) | |
download | poezio-9885203c6799c121f5bc8a733dc1937fe8c1b4d6.tar.gz poezio-9885203c6799c121f5bc8a733dc1937fe8c1b4d6.tar.bz2 poezio-9885203c6799c121f5bc8a733dc1937fe8c1b4d6.tar.xz poezio-9885203c6799c121f5bc8a733dc1937fe8c1b4d6.zip |
Update the plugins to use the PluginAPI
Also:
- Add get_conversation_messages() to PluginAPI
- Make plugins_autoload colon-separated instead of space-separated
(for consistency)
- Replace a JID() with a safeJID() in the uptime plugin
Diffstat (limited to 'plugins/quote.py')
-rw-r--r-- | plugins/quote.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/plugins/quote.py b/plugins/quote.py index ebd9b15e..9b1fd9ad 100644 --- a/plugins/quote.py +++ b/plugins/quote.py @@ -13,7 +13,7 @@ log = logging.getLogger(__name__) class Plugin(BasePlugin): def init(self): for _class in (tabs.MucTab, tabs.ConversationTab, tabs.PrivateTab): - self.add_tab_command(_class, 'quote', self.command_quote, + self.api.add_tab_command(_class, 'quote', self.command_quote, usage='<timestamp>', help='Takes the message received at <timestamp> and insert it in the input, to quote it.', short='Quote a message from a timestamp', @@ -24,9 +24,9 @@ class Plugin(BasePlugin): if len(args) in (1, 2): timestamp = args[-1] else: - return self.core.command_help('quote') + return self.api.run_command('/help quote') if re.match(timestamp_re, timestamp) is None: - return self.core.information('Timestamp has a wrong format.', 'Warning') + return self.api.information('Timestamp has a wrong format.', 'Warning') message = self.find_message_with_timestamp(timestamp) if message: before = self.config.get('before_quote', '') % {'nick': message.nickname or '', @@ -37,12 +37,12 @@ class Plugin(BasePlugin): 'quote': clean_text(message.txt), 'after': after.replace('\\n', '\n').replace('[SP]', ' ')}) else: - self.core.information('No message found for timestamp %s.' % timestamp, 'Warning') + self.api.information('No message found for timestamp %s.' % timestamp, 'Warning') def find_message_with_timestamp(self, timestamp): # TODO: handle messages with the same # timestamp but not the same day - messages = self.core.get_conversation_messages() + messages = self.api.get_conversation_messages() if not messages: return None for message in messages[::-1]: @@ -57,7 +57,7 @@ class Plugin(BasePlugin): return msg.nickname.lower().startswith(nick.lower()) def time_match(msg): return msg.str_time.endswith(time) - messages = self.core.get_conversation_messages() + messages = self.api.get_conversation_messages() if not messages: return text = the_input.get_text() |