Esempio n. 1
0
    def _next_scheduled_time(self, timezone='LOCAL'):
        supported_timezone_keys = ['LOCAL', 'PLATFORM', 'UTC']
        supported_timezone_items = [
            self._LOCAL_TIMEZONE, self._PLATFORM_TIMEZONE, self._UTC_TIMEZONE
        ]

        if timezone.upper() in supported_timezone_keys:
            timezones = dict(
                zip(supported_timezone_keys, supported_timezone_items))
            return str(self.__next_run_time.astimezone(timezones[timezone]))
        raise NotImplementedError
Esempio n. 2
0
 async def _ships_add(self, ctx, timezone, *, name):
     '''- Add a person to ships\n
     Valid timezone format utc+/-#'''
     with open('cogs/assets/ships.json', 'r') as json_file:
         parsed = json.load(json_file)
     log = logging.getLogger("red.testcog")
     log.setLevel(logging.INFO)
     person = name
     tz = timezone.upper()
     for p in parsed['fleet']:
         if tz == p['tzname'] and person in p['members']:
             await self.bot.say("User already in payout")
         elif tz == p['tzname'] and person not in p['members']:
             p['members'].append(person)
             await self.bot.say(str(person) + " added to " + tz + " payout")
         elif tz != p['tzname']:
             log.debug("Timezone doesn't match")
         else:
             await self.bot.say("Something went wrong...blame Atreyu")
     with open('cogs/assets/ships.json', 'w') as json_file:
         json.dump(parsed, json_file, sort_keys=True, indent=4)
Esempio n. 3
0
 async def _payout_remove(self,ctx,timezone, *, name):
     '''- Remove a person from a payout\n
     Valid timezone format utc+/-#'''
     with open('cogs/assets/payouts.json', 'r') as json_file:
         parsed = json.load(json_file)
     log = logging.getLogger("red.testcog")
     log.setLevel(logging.INFO)
     person = name
     tz = timezone.upper()
     for p in parsed['squad']:
         if tz == p['tzname'] and person not in p['members']:
             await self.bot.say("User not in payout")
         elif tz == p['tzname'] and person in p['members']:
             p['members'].remove(person)
             await self.bot.say(str(person) +" removed from "+ tz + " payout")
         elif tz != p['tzname']:
             log.debug("Timezone doesn't match")
         else:
             await self.bot.say("Something went wrong...blame Cherno")
     with open('cogs/assets/payouts.json', 'w') as json_file:
         json.dump(parsed,json_file, sort_keys= True, indent=4)