def setUp(self): cassiopeia.apply_settings(cassiopeia.get_default_config()) cassiopeia.set_riot_api_key(os.environ.get('RIOT_API_KEY')) cassiopeia.apply_settings({"global": {"default_region": "NA"}})
from datetime import datetime import sys, json # constants API_KEY = 'RGAPI-ed3facc5-b751-4caa-9e38-b8f282455a53' API_REGION = Region.europe_west CURRENT_SEASON = Season.season_9 QUEUES = {Queue.ranked_solo_fives} COMPUTABLE_MATCH_COUNT = 5 OUTPUT_FILE = 'players.json' player_history = {} SAVE_AFTER_RECORD = True TIME_DIFFERENCE_CHECK = 1 # in hours # library settings settings = cass.get_default_config() settings['logging']['print_calls'] = False cass.apply_settings(settings) cass.set_riot_api_key(API_KEY) # This overrides the value set in your configuration/settings. cass.set_default_region(API_REGION) # functions def load_players(): global player_history try: with open(OUTPUT_FILE, 'r') as f: player_history = json.load(f) except: pass
"pipline": { ..., "ChampionGG": { "package": "cassiopeia_championgg", "api_key": "CHAMPIONGG_KEY" }, ... } where `"CHAMPIONGG_KEY"` should be replaced with your champion.gg api key or with an environment variable containing it. """ import cassiopeia as cass from cassiopeia import Champion config = cass.get_default_config() config["pipeline"]["ChampionGG"] = { "package": "cassiopeia_championgg", "api_key": "CHAMPIONGG_KEY" } cass.apply_settings(config) def get_champions(): annie = Champion(name="Annie", id=1, region="NA") print(annie.name) print(annie.championgg.win_rate) print(annie.championgg.play_rate) print(annie.championgg.play_rate_by_role) print(annie.championgg.ban_rate)
import datetime import cassiopeia as cass from cassiopeia import Summoner import discord from discord.ext import commands from objects.player import Player from riotwatcher import ApiError, LolWatcher from settings import RIOT_API_TOKEN cass.apply_settings(cass.get_default_config()) cass.set_riot_api_key(RIOT_API_TOKEN) cass.set_default_region("las") watcher = LolWatcher(RIOT_API_TOKEN) default_region = "la2" class Summoners(commands.Cog): def __init__(self, bot): self.bot = bot @commands.command() async def info(self, ctx, *, name: str): """Display information on a summoner""" author = ctx.author player = None try: player = Player(name) except ApiError as err: if err.response.status_code == 429:
lolapi.Tier.master: 'M', lolapi.Tier.grandmaster: 'GM', lolapi.Tier.challenger: 'CH', } DIVISION_SHORT = { lolapi.Division.one: '1', lolapi.Division.two: '2', lolapi.Division.three: '3', lolapi.Division.four: '4', } load_dotenv(verbose=True) cwd = os.getcwd() settings = lolapi.get_default_config() apiMode = os.getenv('API_MODE') if apiMode == 'kernel': settings['pipeline'] = { 'Cache': {}, 'SimpleKVDiskStore': { 'package': 'cassiopeia_diskstore', 'path': cwd + '\\tmp' }, 'DDragon': {}, 'Kernel': { 'server_url': os.getenv('API_KERNEL_URL'), 'port': os.getenv('API_KERNEL_PORT') } }
import cassiopeia as cass import requests import ujson ##################################################################################################################################################################### ## Settings ######################################################################################################################################################### ##################################################################################################################################################################### settDefault = cass.get_default_config() print(settDefault) ##################################################################################################################################################################### ## getMatchByID ##################################################################################################################################################### ##################################################################################################################################################################### cass.get_match()