import time
from bento import console, store
from bento.crons.job import Job

class PeriodicMessageCron(Job):

    def __init__(self, conf, queue=None):
        super().__init__(conf, queue)

        self.messages = self.params['messages']
        self.current = 0


    def main(self):
        if self.current >= len(self.messages):
            self.current = 0
        
        self.log(self.messages[self.current])
        self.announce(self.messages[self.current])
        
        self.last_run = time.time()

        self.current += 1