예제 #1
0
 async def postSongUpdates1min(self):
     await self.bot.wait_until_ready()
     while not self.bot.is_closed():
         try:
             EnEventID = await GetCurrentEventID('en')
         except Exception as e:
             print('Failed posting 1 minute song data. Exception: ' + str(e))            
         if EnEventID:
             timeLeft = await GetEventTimeLeftSeconds('en', EnEventID)
             if(timeLeft > 0):
                 message = await t10membersformatting('en', EnEventID, True, 158699060893581313)
                 if message != "This event doesn't have a song ranking.":
                     #await t10logging('en', eventid, True)
                     ids = getChannelsToPost(1, 'en')
                     for i in ids:
                         channel = self.bot.get_channel(i)
                         if channel != None:
                             try:
                                 for x in message:
                                     await channel.send(x)
                             except (commands.BotMissingPermissions, discord.errors.NotFound, discord.errors.Forbidden): 
                                 LoopRemovalUpdates = self.bot.get_channel(523339468229312555)
                                 await LoopRemovalUpdates.send('Removing 1 minute updates from channel: ' + str(channel.name) + " in server: " + str(channel.guild.name))
                                 removeChannelFromDatabaseSongs(channel)
         timeStart = datetime.now()
         timeFinish = (timeStart + timedelta(minutes=1)).replace(second=0, microsecond=0).timestamp()
         timeStart = timeStart.timestamp()
         await asyncio.sleep(timeFinish - timeStart)
예제 #2
0
 async def post_t10_updates(self, server: str, interval: int):
     await self.bot.wait_until_ready()
     while not self.bot.is_closed():
         try:
             event_id = await GetCurrentEventID(server)
         except Exception as e:
             print(f'Failed posting {interval} minute data for {server}.\nException: ' + {e})            
         if event_id:
             time_left = await GetEventTimeLeftSeconds(server, event_id)
             if(time_left > 0):
                 message = await t10formatting(server, event_id, True)
                 ids = getChannelsToPost(interval, server)
                 for i in ids:
                     channel = self.bot.get_channel(i)
                     if channel != None:
                         try:
                             await channel.send(message)
                         except (commands.BotMissingPermissions, discord.errors.NotFound, discord.errors.Forbidden): 
                             LoopRemovalUpdates = self.bot.get_channel(523339468229312555)
                             await LoopRemovalUpdates.send(f'Removing {interval} updates from channel: {channel.name} in server: {channel.guild.name}')
                             removeChannelFromDatabase(channel, interval, server)
         timeStart = datetime.now()
         if interval == 2:
             if (timeStart.minute % 2) != 0: 
                 timeFinish = (timeStart + timedelta(minutes=1)).replace(second=0, microsecond=0).timestamp()
             else:
                 timeFinish = (timeStart + timedelta(minutes=2)).replace(second=0, microsecond=0).timestamp()
         else:
             timeFinish = (timeStart + timedelta(hours=1)).replace(minute=0, second=0, microsecond=0).timestamp()
         timeStart = timeStart.timestamp()
         await asyncio.sleep(timeFinish - timeStart)