PykeBot2.models package
Submodules
PykeBot2.models.data_models module
Provides data models for Player, Team, Team list and Team list list objects. Further also Error and Message objects are also defined. All of them are subclasses of Payload which is used in Query. Finally also Rank is defined.
All payload subclasses define to str and to discord str functions which are used by the output formatter Player, Team, Team list and Team list list also define extended to str functions which display further information on the Players and the Rank if possible.
- author
Jonathan Decker
- class PykeBot2.models.data_models.Error(content: str)
Bases:
PykeBot2.models.data_models.Payload
- content: str
- discord_str()
- class PykeBot2.models.data_models.Message(content: str)
Bases:
PykeBot2.models.data_models.Payload
- content: str
- discord_str()
- class PykeBot2.models.data_models.Payload
Bases:
object
- discord_extended_str()
- discord_str()
- extended_str()
- class PykeBot2.models.data_models.Player(sum_name)
Bases:
PykeBot2.models.data_models.Payload
Saves information on a single league account
- discord_str()
- opgg: str
- rank: PykeBot2.models.data_models.Rank = Rank()
- summoner_name: str
- class PykeBot2.models.data_models.Rank(rank_string: Optional[str] = None, rank_int: Optional[int] = None)
Bases:
object
Saves a player rank as string and integer
- rank_int = -1
- rank_string = 'Unknown'
- class PykeBot2.models.data_models.Team(name, players)
Bases:
PykeBot2.models.data_models.Payload
Saves information for a team of league players
- average_rank: PykeBot2.models.data_models.Rank = None
- build_op_gg_multi_link()
construct a valid op.gg multi link for the given summoner names :return: String, url to the multilink for the given names
- discord_extended_str()
- discord_str()
- extended_str()
- max_rank: PykeBot2.models.data_models.Rank = None
- multi_link: str
- name: str
- players: List[PykeBot2.models.data_models.Player]
- top5_average_rank = None
- class PykeBot2.models.data_models.TeamList(name, teams)
Bases:
PykeBot2.models.data_models.Payload
Saves a list of teams and the name of the list
- discord_extended_str()
- discord_str()
- extended_str()
- name: str
- teams: List[PykeBot2.models.data_models.Team]
- class PykeBot2.models.data_models.TeamListList(team_lists)
Bases:
PykeBot2.models.data_models.Payload
Saves a list of TeamList objects
- discord_extended_str()
- discord_str()
- extended_str()
- team_lists: List[PykeBot2.models.data_models.TeamList]
PykeBot2.models.errors module
- exception PykeBot2.models.errors.InvalidForwardToError
Bases:
Exception
- Description
Raised when the forward_to of a query could not be matched
- exception PykeBot2.models.errors.InvalidNextStepError
Bases:
Exception
- Description
Raised when the next_step of a query could not be matched
- exception PykeBot2.models.errors.NotFoundResponseError
Bases:
Exception
- Description
Raised when stalker gets Error Code 404 Not found for a request
- exception PykeBot2.models.errors.PayloadCreationError
Bases:
Exception
- Description
Raised when attempting to create a payload object and not a subclass
- exception PykeBot2.models.errors.ServerErrorResponseError
Bases:
Exception
- Description
Raised when a stalker gets Error Code 5xx for a request
- exception PykeBot2.models.errors.TokenLoadingError
Bases:
Exception
- Description
Raised when load_token is unable to load a token
PykeBot2.models.lookup_tables module
Contains various lookup tables :author: Jonathan Decker
- PykeBot2.models.lookup_tables.all_flags_lookup = {'f', 'file', 'group', 'no-api', 'r', 'rank', 'ranks'}
lookup tables for query parameters
- PykeBot2.models.lookup_tables.battlefy_base_url = 'battlefy.com'
help message returned when calling a help command
- PykeBot2.models.lookup_tables.debug_flag = False
Version number TODO: Keep version number up to date!
- PykeBot2.models.lookup_tables.forward_to_lookup = {'backend', 'discord', 'frontend'}
lookup tables for websites and website key words
- PykeBot2.models.lookup_tables.help_message = "Welcome to PykeBot2!\n\nEvery command has the pattern:\n.pb command [flags] [data]\nwhere valid commands are 'stalk' and 'help'.\n\nstalk takes a valid url to a tournament as data and stalks its teams and players.\nSupported for stalking are Prime League, Toornament, Summoners Inn and Battlefy.\n\nstalk accepts the flags:\n'rank', for adding ranks to each player via op.gg and\n'file', for output as file instead of as chat messages\n\nFor example: .pb stalk rank file <url>\nwould return teams and players for the given <url> with ranks as a file.\n\nhelp returns this message and ignores any flags or data.\nFor further information on PykeBot2 see:\nhttps://github.com/Twalord/PykeBot2\n\nAdditional flags: \n'group' to force prime league group stalker instead of season stalker.\n'no-api' to force using the HTML scraper instead of an api."
Uniliga Seitenwahl rules, as we tend to forget or confuse them
- PykeBot2.models.lookup_tables.last_updated = '01.05.2022'
lookup tables for commands and flags
- PykeBot2.models.lookup_tables.uniliga_seitenwahl_rules = '§ 3.2.2 Best-of-2 \nJedes Team spielt je einmal auf der linken und auf der rechten Seite.\nDas auf Toornament zuerst genannte Team darf dabei im ersten Spiel die Seite wählen.'
lookup tables for rank_stalker
PykeBot2.models.query module
Query is the main object used for carrying information between different submodules. Normally a command from the user interface is represented by a single Query, but in some cases additional Queries carrying Messages might be created.
- author
Jonathan Decker
- class PykeBot2.models.query.Query(context_type: str, forward_to: str, next_step: str, raw_command: str = '', discord_channel: None.Message.channel = None, data: str = '', output_message: str = '', flags: Set[str] = None, payload: PykeBot2.models.data_models.Payload = None)
Bases:
object
- Description
Class for any type of data that is sent around via Queues.
Should mainly be created by ingoing interfaces. While processing the query the fields should be further filled out and updated using update query function.
- context_type: str
- data: str
- discord_channel: None.Message.channel
- flags: Set[str]
- forward_to: str
- next_step: str
- output_message: str
- payload: PykeBot2.models.data_models.Payload
- raw_command: str
- update_query(forward_to: str, next_step: str, data: Optional[str] = None, flags: Optional[Set[str]] = None, output_message: Optional[str] = None, payload: Optional[PykeBot2.models.data_models.Payload] = None)
- Description
Updates query information, should be used instead of directly modifying attributes as some checks are
in place to validate the new values. :param forward_to: The next sub module that needs to handle the query. Used by the query forwarder. :type forward_to: str :param next_step: The next step in processing the command read by the submodule receiving the query. :type next_step: str :param data: Input data from the command, usually urls for stalking. :type data: str :param flags: A set of strings which sets additional options like output as file or stalk ranks. :type flags: Set[str] :param output_message: :type output_message: :param payload: Data model that carries the data produced by the backend, a message or an error message. :type payload: Payload :return: None :rtype: None