2013-04-13 20:33:06 +00:00
|
|
|
"""
|
|
|
|
This plugin adds a message at 00:00 in each of your chat tabs saying that the
|
|
|
|
date has changed.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2011-09-27 17:15:15 +00:00
|
|
|
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):
|
2013-03-08 21:53:35 +00:00
|
|
|
self.api.remove_timed_event(self.next_event)
|
2011-09-27 17:15:15 +00:00
|
|
|
|
|
|
|
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)
|
2013-03-08 21:53:35 +00:00
|
|
|
self.api.add_timed_event(self.next_event)
|
2011-09-27 17:15:15 +00:00
|
|
|
|
|
|
|
def day_change(self):
|
2013-04-23 22:15:41 +00:00
|
|
|
msg = _("Day changed to %s") % (datetime.date.today().isoformat())
|
2011-09-27 17:15:15 +00:00
|
|
|
|
|
|
|
for tab in self.core.tabs:
|
|
|
|
if (isinstance(tab, tabs.MucTab) or
|
|
|
|
isinstance(tab, tabs.PrivateTab) or
|
|
|
|
isinstance(tab, tabs.ConversationTab)):
|
2011-11-07 23:14:44 +00:00
|
|
|
tab.add_message(msg)
|
2011-09-27 17:15:15 +00:00
|
|
|
|
|
|
|
self.core.refresh_window()
|
|
|
|
self.schedule_event()
|