summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)