summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2016-04-01 19:39:39 +0200
committermathieui <mathieui@mathieui.net>2016-04-01 19:39:39 +0200
commit51566463bdfc609dd5187b2f0d4aecc7ab6477a9 (patch)
tree4ce9042e3b7f0045fa7a0d729adf0e92970e1d0c /plugins
parent0d787998df032bfad24f55c40658f4c583895c12 (diff)
downloadpoezio-51566463bdfc609dd5187b2f0d4aecc7ab6477a9.tar.gz
poezio-51566463bdfc609dd5187b2f0d4aecc7ab6477a9.tar.bz2
poezio-51566463bdfc609dd5187b2f0d4aecc7ab6477a9.tar.xz
poezio-51566463bdfc609dd5187b2f0d4aecc7ab6477a9.zip
Fix #3181 (make /marquee work in all chat tabs)
Detecting errors would be a pain though
Diffstat (limited to 'plugins')
-rw-r--r--plugins/marquee.py23
1 files 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 <marquee/> 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 <marquee/> 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)