Exemplo n.º 1
0
    def queue_announcements(self):
        try:
            next_trigger = Game.select().order_by(
                (Game.next_announcement).asc()).where(
                    Game.next_announcement != None).limit(1).get()
        except Game.DoesNotExist:
            return

        self.announce_task.set_next_schedule(next_trigger.next_announcement)
Exemplo n.º 2
0
 def trigger_announcement(self):
     games = Game.select().where(
         Game.next_announcement < (datetime.utcnow() +
                                   timedelta(seconds=1)))
     for game in games:  # type: Game
         message = game.a_message
         channel = self.state.channels.get(game.a_channel)
         if not channel:
             self.log.warning(
                 'Not triggering announcement, channel %s was not found!',
                 game.a_channel)
         channel.send_message(message)
         game.set_interval(game.interval)
         next_announcement = Eventual(game.announce_next(self))
         next_announcement.set_next_schedule(datetime.utcnow() +
                                             timedelta(days=2))
     self.queue_announcements()
Exemplo n.º 3
0
 def db_down(self, event):
     """Download all games in the DB as JSON file"""
     games_json = {}
     games = Game.select()
     for game in games: # type: Game
         game_json = {
             'alias': game.alias,
             'desc': game.desc,
             'join_role': game.join_role,
             'time_msg': game.time_message,
             'a_channel': game.a_channel,
             'a_message': game.a_message,
             'interval': game.interval,
             'attendees': game.attendees,
             'join_src': game.join_src,
             'play_src': game.play_src
         }
         games_json[game.name] = game_json
     event.msg.reply('Here is your file!', attachments=[('database.json', json.dumps(games_json))])