From 51566463bdfc609dd5187b2f0d4aecc7ab6477a9 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 1 Apr 2016 19:39:39 +0200 Subject: Fix #3181 (make /marquee work in all chat tabs) Detecting errors would be a pain though --- plugins/marquee.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/plugins/marquee.py b/plugins/marquee.py index 102f54ff..3e183e01 100644 --- a/plugins/marquee.py +++ b/plugins/marquee.py @@ -46,26 +46,37 @@ class Plugin(BasePlugin): default_config = {"marquee": {"refresh": 1.0, "total_duration": 30, "padding": 20}} def init(self): - self.add_tab_command(tabs.MucTab, 'marquee', self.command_marquee, 'Replicate the behavior in a message') + for tab_t in [tabs.MucTab, tabs.ConversationTab, tabs.PrivateTab]: + self.add_tab_command(tab_t, 'marquee', self.command_marquee, + 'Replicate the behavior in a message') @command_args_parser.raw def command_marquee(self, args): tab = self.api.current_tab() tab.command_say(args) + is_muctab = isinstance(tab, tabs.MucTab) msg_id = tab.last_sent_message["id"] jid = tab.name - self.api.add_timed_event(self.api.create_delayed_event(self.config.get("refresh"), self.delayed_event, jid, args, msg_id, 0, 0)) + event = self.api.create_delayed_event(self.config.get("refresh"), + self.delayed_event, + jid, args, msg_id, 0, 0, + is_muctab) + self.api.add_timed_event(event) - def delayed_event(self, jid, body, msg_id, step, duration): + def delayed_event(self, jid, body, msg_id, step, duration, is_muctab): if duration >= self.config.get("total_duration"): return message = self.core.xmpp.make_message(jid) - message["type"] = "groupchat" + message["type"] = "groupchat" if is_muctab else "chat" message["body"] = move(body, step, self.config.get("padding")) message["replace"]["id"] = msg_id message.send() - self.api.information("refresh : %s" % self.config.get("refresh")) - self.api.add_timed_event(self.api.create_delayed_event(self.config.get("refresh"), self.delayed_event, jid, body, message["id"], step + 1, duration + self.config.get("refresh"))) + event = self.api.create_delayed_event(self.config.get("refresh"), + self.delayed_event, jid, body, + message["id"], step + 1, + duration + self.config.get("refresh"), + is_muctab) + self.api.add_timed_event(event) -- cgit v1.2.3