def get_idol_names() -> list: """ Gets a list of every idol name (Last First) :return: List of names """ path = data_path.joinpath('names.json') url = 'http://schoolido.lu/api/idols' size_resp = get(url) if size_resp.status_code != 200: return __local_names(path) size = size_resp.json().get('count', None) if not size: return __local_names(path) params = {'page_size': str(size)} names_resp = get(url, params=params) if names_resp.status_code != 200: return __local_names(path) result_list = names_resp.json().get('results', None) if not result_list: return __local_names(path) names = [res['name'] for res in result_list] with path.open('w+') as f: dump(names, f) return names
def __init__(self, wows_api: WowsAsync, logger): """ :param wows_api: WowsAsync instance. :param logger: the logger. """ self.logger = logger self.wows_api = wows_api self.expected_and_coeff = None self.ship_dict = None self.players = { Region.NA: {}, Region.EU: {}, Region.RU: {}, Region.AS: {} } self.e_and_c_path = data_path.joinpath('expected_and_coeff.json') self.ship_path = data_path.joinpath('ship_dict.json')
def clean(include=None): names = ('logs', 'dumps', 'music_cache') if include: for name in include: assert name in names names = include it = chain(*(data_path.joinpath(n).iterdir() for n in names)) for file in it: if not file.name.startswith('.'): try: file.unlink() except (FileNotFoundError, ValueError, OSError): continue
async def run(): session = ClientSession() config = Config('config.json') start_time = int(time()) logger = setup_logging(start_time, data_path.joinpath('logs')) if config.console_logging: logger.addHandler(get_console_handler()) v = f'{vs.releaselevel} {vs.major}.{vs.minor}.{vs.micro}' if vs.serial: v += f'-{vs.serial}' anime_search = await AnimeSearcher.from_sqlite( {'user': config.mal_user, 'password': config.mal_pass}, DB_PATH / 'minoshiro.db', cache_pages=1, cache_mal_entries=40, logger=logger ) session_manager = anime_search.session_manager data_manager = DataManager(connect(f'{DB_PATH / "yasen_db"}')) wows_api = WowsAsync(config.wows, session) wows_manager = await WowsManager.wows_manager( session_manager, wows_api, logger ) bot = Yasen( logger=logger, version=v, config=config, start_time=start_time, data_manager=data_manager, anime_search=anime_search, wows_manager=wows_manager, wows_api=wows_api ) karen_files = [Path(f) for f in data_path.joinpath('Karen').iterdir()] kanna_files = [Path(f) for f in data_path.joinpath('Kanna').iterdir()] cogs = [Listeners(bot), Fun(bot), Weeb(bot, kanna_files, karen_files), BotInfo(bot), Nsfw(bot), Osu(bot), Utility(bot), Moderation(bot), WorldOfWarships(bot), Music(bot), OwnerOnly(bot)] return bot, cogs
def __init__(self, bot: HahaNoUR): self.bot = bot with data_path.joinpath('info.txt').open() as f: self.info_msg = f.read()
async def chensaw(self, ctx: Context): """ Description: Display a chensaw gif. Usage: "`{prefix}chensaw`" """ await ctx.send(file=File(str(data_path.joinpath('chensaw.gif'))))
async def ayaya(self, ctx: Context): """ Description: "Ayaya!" Usage: "`{prefix}ayaya`" """ await ctx.send(file=File(str(data_path.joinpath('ayaya.png'))))
def __init__(self, bot: Yasen): self.bot = bot self.mention = None self.mention_msg = None self.o7 = File(str(data_path.joinpath('o7.gif')))