def __init__(self, bot): self.bot = bot with open('data/options.json') as f: options = json.load(f) if 'CR_TAG' not in options: self.tag = None else: self.tag = options['CR_TAG'] self.client = crasync.Client()
def __init__(gh, bot): gh.bot = bot with open('data/options.json') as f: options = json.load(f) if 'CR_TAG' not in options: gh.tag = None else: gh.tag = options['CR_TAG'] gh.client = crasync.Client()
def __init__(self, bot): self.bot = bot with open('data/config.json') as f: config = json.load(f) if 'TAG' not in config: tag = None else: tag = config['TAG'] self.tag = os.environ.get('TAG') or tag self.client = crasync.Client()
async def main(loop): client = crasync.Client() profile = await client.get_profile('2CYUUCC8') print(profile) print('Current Trophies: ' + str(profile.current_trophies)) chest_cycle = ', '.join([profile.get_chest(x) for x in range(10)]) print(chest_cycle) # next 9 chests. await profile.update() # updating the info try: clan = await profile.get_clan() # get the players full clan info except ValueError: print('No Clan') else: print('Clan: '+ str(clan)) print('Members: ' + str(len(clan.members))) await clan.update() # updating the info highest = await clan.members[0].get_profile() # top player print('Clan Top Player: '+ str(highest)) constants = await client.get_constants() print(constants.cards['knight'].name) # Card constants. client.close() # you gotta do this if you finish with it ##################### # Temporary clients # ##################### profile = await crasync.get_profile('8UUC9QYG') print(profile) clan = await profile.get_clan() print(clan) # (Less efficient) # In a larger application like a discord bot, # its good to have a persistant client print('--------------\n\n') # Getting full profiles for each member of the clan. tasks = [] for member in clan.members: fut = loop.create_task(get_profile_task(member)) tasks.append(fut) t1 = time.time() done, pending = await asyncio.wait(tasks) t2 = time.time() print(t2-t1)
def __init__(self): super().__init__(command_prefix=None) self.session = aiohttp.ClientSession(loop=self.loop) self.cr = crasync.Client(self.session) self.uptime = datetime.datetime.utcnow() self.commands_used = defaultdict(int) self.process = psutil.Process() self.remove_command('help') self.messages_sent = 0 self.maintenance_mode = False self.psa_message = None self.loop.create_task(self.backup_task()) self._add_commands() self.load_extensions()
def __init__(self, **attrs): super().__init__(command_prefix=self.get_pre, self_bot=True) self.session = aiohttp.ClientSession(loop=self.loop) self.cr = crasync.Client(self.session) self.process = psutil.Process() self._extensions = [ x.replace('.py', '') for x in os.listdir('cogs') if x.endswith('.py') ] self.last_message = None self.messages_sent = 0 self.commands_used = defaultdict(int) self._add_commands() self.load_extensions()
async def main(): client = crasync.Client() profile = await client.get_profile('2CYUUCC8') print(profile) print(profile.current_trophies) await asyncio.sleep(5) await profile.update() # updating the info clan = await profile.get_clan() # get the players full clan info print(clan) print(len(clan.members)) await asyncio.sleep(5) await clan.update() # updating the info highest = await clan.members[0].get_profile() print(highest) # top player
def __init__(self, bot): self.bot = bot session = getattr(bot, 'session', None) self.cr = crasync.Client(session) # The client.