Пример #1
0
 def remind(self, id_=0):
     if id_ not in self.tasks:
         return
     self.api.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.api.add_timed_event(timed_event)
Пример #2
0
 def set_paused_delay(self, composing):
     """
     we create a timed event that will put us to paused
     in a few seconds
     """
     if not config.get_by_tabname('send_chat_states', self.general_jid):
         return
     # First, cancel the delay if it already exists, before rescheduling
     # it at a new date
     self.cancel_paused_delay()
     new_event = timed_events.DelayedEvent(4, self.send_chat_state,
                                           'paused')
     self.core.add_timed_event(new_event)
     self.timed_event_paused = new_event
     new_event = timed_events.DelayedEvent(
         30, self.send_chat_state,
         'inactive' if self.inactive else 'active')
     self.core.add_timed_event(new_event)
     self.timed_event_not_paused = new_event
Пример #3
0
    def command_remind(self, arg):
        args = common.shell_split(arg)
        if len(args) < 2:
            return
        time = common.parse_str_to_secs(args[0])
        if not time:
            return

        self.tasks[self.count] = (time, args[1])
        timed_event = timed_events.DelayedEvent(time, self.remind, self.count)
        self.api.add_timed_event(timed_event)
        self.api.information(
            'Task %s added: %s every %s.' %
            (self.count, args[1], common.parse_secs_to_str(time)), 'Info')
        self.count += 1
Пример #4
0
    def command_delayed(self, args):
        if args is None:
            self.core.command.help('send_delayed')
            return
        delay_str, txt = args
        delay = common.parse_str_to_secs(delay_str)
        if not delay:
            self.api.information('Failed to parse %s.' % delay_str, 'Error')
            return

        tab = self.api.current_tab()
        timed_event = timed_events.DelayedEvent(delay, self.say, (tab, txt))
        self.api.add_timed_event(timed_event)
        self.api.information(
            'Delayed message will be sent in %ds (%s).' % (delay, delay_str),
            'Info')