def get_options(): db: Session = self.cfeed.service.get_session() _options = dOpt.mapper_index_withAdditional( self.cfeed.discord_client, message_object) _options.set_main_header( "Remove an entity from being tracked in this feed:") try: for pilot in db.query(tb_Filter_characters).filter( tb_Filter_characters.channel_id == self.cfeed.channel_id).all(): _options.add_option( dOpt.option_returns_object( name=pilot.object_item.get_name(), return_object=pilot)) for corp in db.query(tb_Filter_corporations).filter( tb_Filter_corporations.channel_id == self.cfeed.channel_id).all(): _options.add_option( dOpt.option_returns_object( name=corp.object_item.get_name(), return_object=corp)) for ali in db.query(tb_Filter_alliances).filter( tb_Filter_alliances.channel_id == self.cfeed.channel_id).all(): _options.add_option( dOpt.option_returns_object( name=ali.object_item.get_name(), return_object=ali)) except Exception as ex: print(ex) finally: db.close() return _options
async def InsightOptionRequired_setAppearance( self, message_object: discord.Message): """Change visual appearance - Set the visual appearance of rich embeds.""" def set_appearance(app_id): db: Session = self.cfeed.service.get_session() try: __row: tb_channels = db.query(tb_channels).filter( tb_channels.channel_id == self.cfeed.channel_id).one() __row.appearance_id = app_id db.merge(__row) db.commit() except Exception as ex: print(ex) raise InsightExc.Db.DatabaseError finally: db.close() _options = dOpt.mapper_index_withAdditional(self.cfeed.discord_client, message_object) _options.set_main_header( "Select a rich embed appearance. Appearances allow you to select a template for " "killmail presentation and differ in verbosity, size, and the amount of information " "provided. See https://github.com/Nathan-LS/Insight/wiki/Rich-Embed-Appearance for " "sample previews of each appearance. Note: appearances can be changed after feed " "creation by running the '!settings' command.") for ap in self.cfeed.linked_visual_base().appearance_options(): _options.add_option( dOpt.option_returns_object(name=ap.get_desc(), return_object=ap.appearance_id())) a_id = await _options() await self.cfeed.discord_client.loop.run_in_executor( None, partial(set_appearance, a_id)) await self.reload(message_object)
async def InsightOptionRequired_tracktype(self, message_object:discord.Message): """Show losses/kills - Set the feed to one of three modes for tracked entities: show losses only, show kills only, show both kills and losses""" def set_mode(option): db:Session = self.cfeed.service.get_session() try: __row: tb_enfeed = db.query(tb_enfeed).filter(tb_enfeed.channel_id == self.cfeed.channel_id).one() __row.show_mode = option db.merge(__row) db.commit() except Exception as ex: print(ex) raise InsightExc.Db.DatabaseError finally: db.close() __options = dOpt.mapper_index_withAdditional(self.cfeed.discord_client, message_object) __options.set_main_header("Select the KM viewing mode for this entity feed.") __options.add_option(dOpt.option_returns_object( name="Show losses only - Only losses involving your tracked entities will be posted", return_object=enum_kmType.losses_only)) __options.add_option(dOpt.option_returns_object( name="Show kills only - Only kills where your tracked entities were attackers will be posted", return_object=enum_kmType.kills_only)) __options.add_option(dOpt.option_returns_object( name="Show kills and losses - Both kills and losses involving feed tracked entities will be posted", return_object=enum_kmType.show_both)) __selected_option = await __options() await self.cfeed.discord_client.loop.run_in_executor(None, partial(set_mode, __selected_option)) await self.reload(message_object)
def make_options(search_str) -> dOpt.mapper_index: __options = dOpt.mapper_index_withAdditional(self.cfeed.discord_client, message_object) __options.set_main_header("Select the entity you wish to add.") db: Session = self.cfeed.service.get_session() def header_make(row_list:List[tb_alliances],header_text): if len(row_list) > 0: __options.add_header_row(header_text) for i in row_list: __options.add_option(dOpt.option_returns_object(name=i.get_name(), return_object=i)) try: header_make(db.query(tb_alliances).filter(tb_alliances.alliance_name.ilike("%{}%".format(search_str))).all(),"Alliances") header_make(db.query(tb_corporations).filter(tb_corporations.corporation_name.ilike("%{}%".format(search_str))).all(),"Corporations") header_make(db.query(tb_characters).filter(tb_characters.character_name.ilike("%{}%".format(search_str))).all(),"Pilots") __options.add_header_row("Additional Options") __options.add_option(dOpt.option_returns_object("Search again", return_object=None)) except Exception as ex: print(ex) db.rollback() finally: db.close() return __options
def make_options(search_str) -> dOpt.mapper_index: __options = dOpt.mapper_index_withAdditional(self.cfeed.discord_client, message_object) __options.set_main_header( "Select the entity you wish to add.\nNote: Additional entities can be added or removed after feed creation by running the ‘!settings’ command.") db: Session = self.cfeed.service.get_session() def header_make(row_list:List[tb_alliances],header_text): if len(row_list) > 0: __options.add_header_row(header_text) for i in row_list: __options.add_option(dOpt.option_returns_object(name=i.get_name(), return_object=i)) try: header_make(SearchHelper.search(db, tb_alliances, tb_alliances.alliance_name, search_str), "Alliances") header_make(SearchHelper.search(db, tb_corporations, tb_corporations.corporation_name, search_str), "Corporations") header_make(SearchHelper.search(db, tb_characters, tb_characters.character_name, search_str),"Pilots") __options.add_header_row("Additional Options") __options.add_option(dOpt.option_returns_object("Search again", return_object=None)) return __options except Exception as ex: raise ex finally: db.close()