def __init__(self): super().__init__(command_prefix=os.getenv('PREFIX', '>')) self.session = aiohttp.ClientSession(loop=self.loop) self.mongo = AsyncIOMotorClient(os.getenv('MONGO')) self.statsy_mongo = AsyncIOMotorClient(os.getenv('STATSYMONGO')) self.client = clashroyale.OfficialAPI( os.getenv('CLASHROYALE'), is_async=True, session=self.session, timeout=10, url=os.getenv('SERVER') ) self.remove_command('help') self.add_command(self.ping) self.add_command(self._eval) protected = ('cogs.logging', 'cogs.levelling') for i in os.listdir('cogs'): if i.endswith('.py'): cog_name = 'cogs.' + i.replace('.py', '') if os.name == 'nt' and cog_name in protected: continue try: self.load_extension(cog_name) except Exception as e: traceback.print_exc() else: print(f'Loaded: {cog_name}') self.run(os.getenv('TOKEN'), activity=discord.Game("for Stu's Army!"))
def __init__(self, bot): self.bot = bot self.conv = TagCheck() self.cache = TTLCache(500, 180) scopes = [ "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/firebase.database" ] self.firebase = ServiceAccountCredentials.from_json_keyfile_dict( json.loads(b64decode(os.getenv('firebase')).decode()), scopes=scopes) try: constants = json.loads( requests.get('https://fourjr.herokuapp.com/cr/constants').text) except json.JSONDecodeError: constants = None self.cr = clashroyale.OfficialAPI( os.getenv('clashroyale'), session=self.bot.session, is_async=True, timeout=20, constants=constants, url= f"http://{os.getenv('spike')}/redirect?url=https://api.clashroyale.com/v1" ) self.royaleapi = clashroyale.RoyaleAPI(os.getenv('royaleapi'), session=self.bot.session, is_async=True, timeout=20) if not self.bot.dev_mode: self.bot.clan_update = self.bot.loop.create_task( self.clan_update_loop())
def __init__(self, bot): self.bot = bot self.auth = self.bot.get_cog('crtools').auth self.tags = self.bot.get_cog('crtools').tags self.clans = self.bot.get_cog('crtools').clans self.constants = self.bot.get_cog('crtools').constants self.clash = clashroyaleAPI.OfficialAPI(self.auth.getOfficialToken(), is_async=True)
def __init__(self, bot): self.bot = bot self.settings = dataIO.load_json(settings_path) self.auth = self.bot.get_cog('crtools').auth self.tags = self.bot.get_cog('crtools').tags self.constants = self.bot.get_cog('crtools').constants self.clash = clashroyale.OfficialAPI(self.auth.getOfficialToken(), is_async=True) self.active = False
def __init__(self, bot): self.bot = bot self.user_history = {} self.welcome = dataIO.load_json('data/legend/welcome.json') self.auth = self.bot.get_cog('crtools').auth self.tags = self.bot.get_cog('crtools').tags self.clans = self.bot.get_cog('crtools').clans self.clash = clashroyale.OfficialAPI(self.auth.getOfficialToken(), is_async=True)
def __init__(self, bot): self.bot = bot self.CRregex = re.compile(r"<?(https?:\/\/)?(www\.)?(link\.clashroyale\.com\/invite\/friend)\b([-a-zA-Z0-9/]*)>?") self.BSregex = re.compile(r"<?(https?:\/\/)?(www\.)?(link\.brawlstars\.com\/invite\/friend)\b([-a-zA-Z0-9/]*)>?") self.auth = self.bot.get_cog('crtools').auth self.tags = self.bot.get_cog('crtools').tags self.constants = self.bot.get_cog('crtools').constants self.clash = clashroyale.OfficialAPI(self.auth.getOfficialToken(), is_async=True) self.brawl = brawlstats.Client(self.auth.getBSToken(), is_async=False)
def __init__(self, bot): self.bot = bot self.auth = self.bot.get_cog('crtools').auth self.clans = self.bot.get_cog('crtools').clans self.clash = clashroyale.OfficialAPI(self.auth.getOfficialToken(), is_async=True) self.member_log = dataIO.load_json('data/clanlog/member_log.json') self.discord_log = dataIO.load_json('data/clanlog/discord_log.json') self.last_count = 0
def __init__(self, bot): self.bot = bot self.banks = dataIO.load_json('data/economy/bank.json') self.auth = self.bot.get_cog('crtools').auth self.tags = self.bot.get_cog('crtools').tags self.clans = self.bot.get_cog('crtools').clans self.clash = clashroyale.OfficialAPI(self.auth.getOfficialToken(), is_async=True) self.session = aiohttp.ClientSession()
async def setUp(self): self.location_id = ['global', 57000249] # united states self.player_tags = ['#2P0LYQ', '#2PP'] self.clan_tags = ['#9Q8PYRLL', '#8LQ2P0RL'] self.tournament_tags = ['#2PPV2VUL', '#20RUCV8Q'] self.cr = clashroyale.OfficialAPI(TOKEN, url=URL, is_async=True, loop=self.loop, timeout=30)
async def initialize(self): crapikey = await self.bot.get_shared_api_tokens("crapi") if crapikey["api_key"] is None: raise ValueError("The Clash Royale API key has not been set.") self.crapi = clashroyale.OfficialAPI(crapikey["api_key"], is_async=True) ofcbsapikey = await self.bot.get_shared_api_tokens("ofcbsapi") if ofcbsapikey["api_key"] is None: raise ValueError("The Official Brawl Stars API key has not been set.") self.ofcbsapi = brawlstats.Client(ofcbsapikey["api_key"], is_async=True)
def __init__(self, clan_tag: str, key: str, api: str, sleep_seconds: int) -> None: self.clan_tag: str = clan_tag self.key: str = key self.sleep_seconds = sleep_seconds self.api = api if api.lower() == ROYALE_API: self.client = clashroyale.RoyaleAPI(key, is_async=False) else: self.client = clashroyale.OfficialAPI(key, is_async=False)
def __init__(self, bot): self.bot = bot self.auth = self.bot.get_cog('crtools').auth self.clans = self.bot.get_cog('crtools').clans self.constants = self.bot.get_cog('crtools').constants self.deck = Deck(self.bot) self.clash = clashroyale.OfficialAPI(self.auth.getOfficialToken(), is_async=True, timeout=20) self.moment = time.time() self.completed = [[], []]
def __init__(self, bot): self.bot = bot self.auth = self.bot.get_cog('crtools').auth self.clans = self.bot.get_cog('crtools').clans self.clubs = self.bot.get_cog('crtools').clubs self.tags = self.bot.get_cog('crtools').tags self.clash = clashroyale.OfficialAPI(self.auth.getOfficialToken(), is_async=True) self.brawl = brawlstats.Client(self.auth.getBSToken(), is_async=False) self.member_log = dataIO.load_json('data/clanlog/member_log.json') self.bs_member_log = dataIO.load_json('data/clanlog/bs_member_log.json') self.discord_log = dataIO.load_json('data/clanlog/discord_log.json') self.last_count = 0 self.bs_last_count = 0
def __init__(self): self.loop = asyncio.get_event_loop() self.session = aiohttp.ClientSession(loop=self.loop) self.client = clashroyale.OfficialAPI(os.environ['api_token'], is_async=True, timeout=10, session=self.session, url=os.environ['server']) self.log = logging.getLogger('cr-tournament-finder') self.mongo = AsyncIOMotorClient(os.environ['mongo']) self.is_closed = False try: self.loop.run_until_complete(self.poll()) except KeyboardInterrupt: self.is_closed = True self.close()
def __init__(self, bot): self.bot = bot self.settings = dataIO.load_json(settings_path) self.cards = dataIO.load_json(cards_path) self.auth = self.bot.get_cog('crtools').auth self.tags = self.bot.get_cog('crtools').tags self.constants = self.bot.get_cog('crtools').constants self.clash = clashroyale.OfficialAPI(self.auth.getOfficialToken(), is_async=True) # init card data self.cards_abbrev = {} for k, v in self.cards.items(): for value in v: self.cards_abbrev[value] = k self.cards_abbrev[k] = k
async def initialize(self): crapikey = await self.bot.db.api_tokens.get_raw( "crapi", default={"api_key": None}) if crapikey["api_key"] is None: raise ValueError( "The Clash Royale API key has not been set. Use [p]set api crapi api_key,YOURAPIKEY" ) self.crapi = clashroyale.OfficialAPI(crapikey["api_key"], is_async=True) bsapikey = await self.bot.db.api_tokens.get_raw( "bsapi", default={"api_key": None}) if bsapikey["api_key"] is None: raise ValueError( "The Brawl Stars API key has not been set. Use [p]set api bsapi api_key,YOURAPIKEY" ) self.bsapi = brawlstats.Client(bsapikey["api_key"], is_async=True)
async def initialize(self): crapikey = await self.bot.get_shared_api_tokens("crapi") if crapikey["api_key"] is None: raise ValueError("The Clash Royale API key has not been set.") self.crapi = clashroyale.OfficialAPI(crapikey["api_key"], is_async=True)