async def deserialize(cls, dbcog, user_config: UserConfig, ims: dict): # for numberscroll getting to a gap in monster book, or 1, or last monster if ims.get('unsupported_transition'): return None monster = await get_monster_from_ims(dbcog, ims) alt_monsters = cls.get_alt_monsters_and_evos(dbcog, monster) id_queried_props = await IdViewState.do_query(dbcog, monster) raw_query = ims['raw_query'] # This is to support the 2 vs 1 monster query difference between ^ls and ^id query = ims.get('query') or raw_query query_settings = QuerySettings.deserialize(ims.get('query_settings')) menu_type = ims['menu_type'] original_author_id = ims['original_author_id'] reaction_list = ims.get('reaction_list') fallback_message = ims.get('message') is_child = ims.get('is_child') is_jp_buffed = dbcog.database.graph.monster_is_discrepant(monster) return cls(original_author_id, menu_type, raw_query, query, monster, alt_monsters, is_jp_buffed, query_settings, id_queried_props, fallback_message=fallback_message, reaction_list=reaction_list, is_child=is_child, extra_state=ims)
async def deserialize(cls, dbcog, user_config: UserConfig, ims: dict): if ims.get('unsupported_transition'): return None title = ims['title'] queried_props = await cls.query_from_ims(dbcog, ims) current_page = ims['current_page'] current_index = ims.get('current_index') raw_query = ims['raw_query'] query = ims.get('query') or raw_query query_settings = QuerySettings.deserialize(ims.get('query_settings')) original_author_id = ims['original_author_id'] menu_type = ims['menu_type'] reaction_list = ims.get('reaction_list') child_message_id = ims.get('child_message_id') child_menu_type = ims.get('child_menu_type') child_reaction_list = ims.get('child_reaction_list') idle_message = ims.get('idle_message') return cls(original_author_id, menu_type, query, queried_props, query_settings, title, idle_message, current_page=current_page, current_index=current_index, child_menu_type=child_menu_type, child_reaction_list=child_reaction_list, reaction_list=reaction_list, extra_state=ims, child_message_id=child_message_id)
async def deserialize(cls, dbcog, user_config: UserConfig, ims: dict): if ims.get('unsupported_transition'): return None monster = await get_monster_from_ims(dbcog, ims) alt_versions, gem_versions = await EvosViewState.do_query( dbcog, monster) if alt_versions is None: return None alt_monsters = cls.get_alt_monsters_and_evos(dbcog, monster) raw_query = ims['raw_query'] query = ims.get('query') or raw_query query_settings = QuerySettings.deserialize(ims.get('query_settings')) original_author_id = ims['original_author_id'] menu_type = ims['menu_type'] reaction_list = ims.get('reaction_list') is_jp_buffed = dbcog.database.graph.monster_is_discrepant(monster) return cls(original_author_id, menu_type, raw_query, query, monster, alt_monsters, is_jp_buffed, query_settings, alt_versions, gem_versions, reaction_list=reaction_list, extra_state=ims)
async def deserialize(dbcog, user_config: UserConfig, ims: dict): raw_query = ims['raw_query'] original_author_id = ims['original_author_id'] menu_type = ims['menu_type'] query_settings = QuerySettings.deserialize(ims['query_settings']) mon = await get_monster_from_ims(dbcog, ims) return LeaderSkillSingleViewState(original_author_id, menu_type, raw_query, query_settings, mon)
async def get_monster_from_ims(dbcog, ims: dict): query = ims.get('query') or ims['raw_query'] query_settings = QuerySettings.deserialize(ims.get('query_settings')) resolved_monster_id_str = ims.get('resolved_monster_id') resolved_monster_id = int(resolved_monster_id_str or 0) if resolved_monster_id: return dbcog.database.graph.get_monster(resolved_monster_id, server=query_settings.server) monster = await dbcog.find_monster(query, ims['original_author_id']) return monster
async def deserialize(cls, alcog, _user_config: UserConfig, ims: dict): original_author_id = ims['original_author_id'] menu_type = ims['menu_type'] query_settings = QuerySettings.deserialize(ims.get('query_settings')) reaction_list = ims['reaction_list'] image_idx = ims['current_index'] card = alcog.id_to_card[ims['idx']] return AzurlaneViewState(original_author_id, menu_type, query_settings, card, image_idx, reaction_list=reaction_list)
async def deserialize(cls, dbcog, _user_config: UserConfig, ims: dict): sort_type = ims['sort_type'] paginated_skills = await cls.do_query(dbcog, sort_type) original_author_id = ims['original_author_id'] current_page = ims['current_page'] menu_type = ims['menu_type'] reaction_list = ims['reaction_list'] token_map = dbcog.AWOKEN_SKILL_TOKEN_MAP query_settings = QuerySettings.deserialize(ims.get('query_settings')) return AwakeningListViewState(original_author_id, menu_type, query_settings, sort_type, paginated_skills, current_page, token_map, reaction_list=reaction_list)
async def deserialize(cls, dbcog, _user_config: UserConfig, padle_cog, ims: dict): original_author_id = ims['original_author_id'] menu_type = ims['menu_type'] reaction_list = ims['reaction_list'] current_day = ims['current_day'] num_days = ims['num_days'] query_settings = QuerySettings.deserialize(ims.get('query_settings')) daily_scores_list = await padle_cog.config.save_daily_scores() cur_day_scores = await padle_cog.config.all_scores() if num_days == current_day: return GlobalStatsViewState(original_author_id, menu_type, query_settings, "", current_day=current_day, num_days=num_days, reaction_list=reaction_list, monster=None, stats=cur_day_scores) else: info = daily_scores_list[current_day - 1] m = dbcog.get_monster(int(info[0])) return GlobalStatsViewState(original_author_id, menu_type, query_settings, "", current_day=current_day, num_days=num_days, reaction_list=reaction_list, monster=m, stats=info[1])
async def deserialize(cls, dbcog, user_config: UserConfig, ims: dict): raw_query = ims['raw_query'] original_author_id = ims['original_author_id'] menu_type = ims['menu_type'] query_settings = QuerySettings.deserialize(ims['query_settings']) display_options = ButtonInfoToggles(ims['players_setting'], ims['device_setting'], ims['max_level_setting']) monster = dbcog.get_monster(int(ims['resolved_monster_id'])) alt_monsters = cls.get_alt_monsters_and_evos(dbcog, monster) info = button_info.get_info(dbcog, monster) reaction_list = ims['reaction_list'] return ButtonInfoViewState(original_author_id, menu_type, raw_query, display_options, monster, alt_monsters, info, query_settings, reaction_list=reaction_list)
async def _process_settings(self, original_query: str) -> str: query_settings = QuerySettings.extract(self.flags, original_query) self.index = await self.dbcog.get_index(query_settings.server) return re.sub(r'\s*(--|—)\w+(:{.+?})?(?:\s+|$)', ' ', original_query)
async def query_from_ims(cls, dbcog, ims) -> List["MonsterModel"]: monster_ids = ims['full_monster_list'] query_settings = QuerySettings.deserialize(ims['query_settings']) monster_list = await cls.do_query(dbcog, monster_ids, query_settings.server) return monster_list
async def query_from_ims(cls, dbcog, ims) -> MonsterListQueriedProps: queried_props = await cls.do_query( dbcog, ims['raw_query'], ims['original_author_id'], QuerySettings.deserialize(ims['query_settings'])) return queried_props
async def query_from_ims(cls, dbcog, ims) -> List["MonsterModel"]: monster_list = await cls.do_query( dbcog, ims['raw_query'], ims['original_author_id'], QuerySettings.deserialize(ims['query_settings'])) return monster_list