summaryrefslogtreecommitdiff
path: root/plugins/reminder.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-11-14 00:56:15 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-11-14 00:56:15 +0100
commitf0f9f670b9084761023ba9c594b97a0ad37581ed (patch)
treea6a3b72d68f0f5783875cd721ce5e6686009078a /plugins/reminder.py
parent3ea5eb6163181ba016cfddcc616a171d7f309e76 (diff)
parent920c43dae25b06fd843dc8f8cbbf5e6bc5bf91c0 (diff)
downloadpoezio-f0f9f670b9084761023ba9c594b97a0ad37581ed.tar.gz
poezio-f0f9f670b9084761023ba9c594b97a0ad37581ed.tar.bz2
poezio-f0f9f670b9084761023ba9c594b97a0ad37581ed.tar.xz
poezio-f0f9f670b9084761023ba9c594b97a0ad37581ed.zip
Merge branch 'master' of http://git.louiz.org/poezio
Diffstat (limited to 'plugins/reminder.py')
-rw-r--r--plugins/reminder.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins/reminder.py b/plugins/reminder.py
new file mode 100644
index 00000000..eb63efde
--- /dev/null
+++ b/plugins/reminder.py
@@ -0,0 +1,56 @@
+from plugin import BasePlugin
+import curses
+import common
+import timed_events
+
+class Plugin(BasePlugin):
+
+ def init(self):
+ self.add_command('remind', self.command_remind, "Usage: /reminder <time in seconds> <todo>\nReminder: remind you of <todo> every <time> seconds..", None)
+ self.add_command('done', self.command_done, "Usage: /done <id>\nDone: Stop reminding you do the task identified by <id>", None)
+ self.add_command('tasks', self.command_tasks, "Usage: /tasks\nTasks: List all the current tasks and their ids.", None)
+ self.tasks = {}
+ self.count = 0
+
+ def command_remind(self, arg):
+ args = common.shell_split(arg)
+ if len(args) < 2:
+ return
+ try:
+ time = int(args[0])
+ except:
+ return
+
+ self.tasks[self.count] = (time, args[1])
+ timed_event = timed_events.DelayedEvent(time, self.remind, self.count)
+ self.core.add_timed_event(timed_event)
+ self.count += 1
+
+ def command_done(self, arg="0"):
+ try:
+ id = int(arg)
+ except:
+ return
+ if not id in self.tasks:
+ return
+
+ del self.tasks[id]
+
+ def command_tasks(self, arg):
+ s = ''
+ for key in self.tasks:
+ s += '%s: %s\n' % key, self.tasks[key][1]
+ if s:
+ self.core.information(s, 'Info')
+
+ def remind(self, id=0):
+ if not id in self.tasks:
+ return
+ self.core.information('Task %s: %s' % (id, self.tasks[id][1]), 'Info')
+ if self.config.get('beep', '') == 'true':
+ curses.beep()
+ timed_event = timed_events.DelayedEvent(self.tasks[id][0], self.remind, id)
+ self.core.add_timed_event(timed_event)
+
+
+