Esempio n. 1
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)
Esempio n. 2
0
 async def removeTracking(self,
                          ctx,
                          channel: TextChannel = None,
                          interval: int = 3600,
                          server: str = 'en'):
     if ctx.message.author.guild_permissions.administrator:
         if interval == 2:
             await ctx.send(
                 '2 minute tracking is now a premium feature. Please use `.premium` for more information'
             )
         else:
             valid_intervals = [60, 3600]
             if interval not in valid_intervals:
                 await ctx.send(
                     'Please enter a value of 2 for 2 minute updates or 60/3600 for hourly updates'
                 )
             else:
                 if interval == 60:
                     interval = 3600
                 if channel == None:
                     channel = ctx.channel
             await ctx.send(
                 removeChannelFromDatabase(channel, interval, server))
     else:
         await ctx.send(
             "You must have administrator rights to run this command, {0.author.mention}"
             .format(ctx.message))
Esempio n. 3
0
 async def removeTracking(self,
                          ctx,
                          channel: TextChannel = None,
                          interval: int = 3600,
                          server: str = 'en'):
     if ctx.message.author.guild_permissions.administrator:
         ValidIntervals = [2, 60, 3600]
         if interval not in ValidIntervals:
             await ctx.send(
                 'Please enter a value of 2 for 2 minute updates or 60/3600 for hourly updates'
             )
         else:
             if interval == 60:
                 interval = 3600
             if (channel == None):
                 channel = ctx.channel
         await ctx.send(removeChannelFromDatabase(channel, interval,
                                                  server))
     else:
         msg = "You must have administrator rights to run this command, {0.author.mention}".format(
             ctx.message)
         await ctx.send(msg)