summaryrefslogtreecommitdiff
path: root/plugins/day_change.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-11-09 01:26:54 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-11-09 01:26:54 +0100
commit75ae1772e49a59b373c26d1c942f25edd473921c (patch)
tree65d8faee081db6c3800a48eff7007a4b626e4252 /plugins/day_change.py
parent8f02b6eb8e022ed1d34e0a0b0c7376eaf58acc32 (diff)
parent23d81901e7725bf67363113bc36a6e171bdb2033 (diff)
downloadpoezio-75ae1772e49a59b373c26d1c942f25edd473921c.tar.gz
poezio-75ae1772e49a59b373c26d1c942f25edd473921c.tar.bz2
poezio-75ae1772e49a59b373c26d1c942f25edd473921c.tar.xz
poezio-75ae1772e49a59b373c26d1c942f25edd473921c.zip
Merge branch 'master' of http://git.louiz.org/poezio
Diffstat (limited to 'plugins/day_change.py')
-rw-r--r--plugins/day_change.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/plugins/day_change.py b/plugins/day_change.py
new file mode 100644
index 00000000..14924684
--- /dev/null
+++ b/plugins/day_change.py
@@ -0,0 +1,30 @@
+from gettext import gettext as _
+from plugin import BasePlugin
+import datetime
+import tabs
+import timed_events
+
+class Plugin(BasePlugin):
+ def init(self):
+ self.schedule_event()
+
+ def cleanup(self):
+ self.core.remove_timed_event(self.next_event)
+
+ def schedule_event(self):
+ day_change = datetime.datetime.combine(datetime.date.today(), datetime.time())
+ day_change += datetime.timedelta(1)
+ self.next_event = timed_events.TimedEvent(day_change, self.day_change)
+ self.core.add_timed_event(self.next_event)
+
+ def day_change(self):
+ msg = datetime.date.today().strftime(_("Day changed to %x"))
+
+ for tab in self.core.tabs:
+ if (isinstance(tab, tabs.MucTab) or
+ isinstance(tab, tabs.PrivateTab) or
+ isinstance(tab, tabs.ConversationTab)):
+ tab.add_message(msg)
+
+ self.core.refresh_window()
+ self.schedule_event()