summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-15 21:35:39 +0100
committermathieui <mathieui@mathieui.net>2011-11-15 21:35:39 +0100
commit403406b60a0889b8f064604c9a6147cb06b55455 (patch)
tree5225a26eb7e68f904c8966a585b6f31f9da97d2d /plugins
parentd6ceb78c829746f54b067c79087eb15d47707ac2 (diff)
downloadpoezio-403406b60a0889b8f064604c9a6147cb06b55455.tar.gz
poezio-403406b60a0889b8f064604c9a6147cb06b55455.tar.bz2
poezio-403406b60a0889b8f064604c9a6147cb06b55455.tar.xz
poezio-403406b60a0889b8f064604c9a6147cb06b55455.zip
Add a send_delayed plugins to send messages in some time
Diffstat (limited to 'plugins')
-rw-r--r--plugins/send_delayed.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/plugins/send_delayed.py b/plugins/send_delayed.py
new file mode 100644
index 00000000..61d2d397
--- /dev/null
+++ b/plugins/send_delayed.py
@@ -0,0 +1,43 @@
+from plugin import BasePlugin
+import tabs
+import common
+import timed_events
+
+class Plugin(BasePlugin):
+
+ def init(self):
+ self.add_tab_command(tabs.PrivateTab, 'send_delayed', self.command_delayed, "Usage: /send_delayed <delay> <message>\nSend Delayed: Send <message> with a delay of <delay> seconds.", self.completion_delay)
+ self.add_tab_command(tabs.MucTab, 'send_delayed', self.command_delayed, "Usage: /send_delayed <delay> <message>\nSend Delayed: Send <message> with a delay of <delay> seconds.", self.completion_delay)
+ self.add_tab_command(tabs.ConversationTab, 'send_delayed', self.command_delayed, "Usage: /send_delayed <delay> <message>\nSend Delayed: Send <message> with a delay of <delay> seconds.", self.completion_delay)
+
+ def command_delayed(self, arg):
+ args = common.shell_split(arg)
+ if len(args) != 2:
+ return
+ delay = common.parse_str_to_secs(args[0])
+ if not delay:
+ return
+
+ tab = self.core.current_tab()
+ timed_event = timed_events.DelayedEvent(delay, self.say, (tab, args[1]))
+ self.core.add_timed_event(timed_event)
+
+ def completion_delay(self, the_input):
+ txt = the_input.get_text()
+ args = common.shell_split(txt)
+ n = len(args)
+ if txt.endswith(' '):
+ n += 1
+ if n == 2:
+ return the_input.auto_completion(["60", "5m", "15m", "30m", "1h", "10h", "1d"], '')
+
+ def say(self, args=None):
+ if not args:
+ return
+
+ tab = args[0]
+ # anything could happen to the tab during the interval
+ try:
+ tab.command_say(args[1])
+ except:
+ pass