The Standard Showdown Message
The Message object
The base class for all specific Message subclasses to be built from.
When parsing a string message, you should directly use this class's from_message
function, which will
auto-identify which subclass (if any) the given string belongs to.
Across all Messages, you will be able to access both MTYPE and MESSAGE, though you shouldn't need to access MESSAGE directly. (If you do, then we must be missing some data that exists in the raw string)
ATTRIBUTE | DESCRIPTION |
---|---|
MTYPE |
The message type of this message. Must be a vaild showdown general message.
TYPE:
|
MESSAGE |
The raw message line as sent from showdown. Shouldn't need to be used but worth keeping.
TYPE:
|
from_message(message)
staticmethod
Create a specific Message object from a raw string message.
This is used for general Showdown Messages, compared to the BattleMessage class meant for battle details.
PARAMETER | DESCRIPTION |
---|---|
message |
The newline-stripped single string message as sent by the server.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Message
|
An initialized subclass of
TYPE:
|
Message Subclasses
Contains BaseModels for Message parsing and processing.
Remember to use Message.from_message directly, unless you are building test cases where you want to assert that
a given message leads to a certain subclass of Message. from_message
will auto-detect which MType the given
message corresponds to, and return the associated subclass (or an error detailing what went wrong) for you.
Message_challstr
Message containing a login challenge string.
ATTRIBUTE | DESCRIPTION |
---|---|
CHALLSTR |
The string challenge string
TYPE:
|
Use Case(s)
- Gives the user a challenge string to submit to the login server to get a token
Message Format(s)
- |challstr|CHALLSTR
Input Example(s)
- TODO
Message_customgroups
Message containing info about server custom groups.
ATTRIBUTE | DESCRIPTION |
---|---|
CUSTOM_GROUPS |
The list of custom groups
TYPE:
|
Use Case(s)
- To communicate all usergroups
Message Format(s)
- |customgroups|CUSTOMGROUPS
Input Example(s)
- TODO
Message_formats
Message containing info about server enabled formats.
ATTRIBUTE | DESCRIPTION |
---|---|
FORMATS |
The list of formats
TYPE:
|
Use Case(s)
- To communicate all available formats the user can play
Message Format(s)
- |formats|FORMATSLIST
Input Example(s)
- TODO
Message_init
Message notifying about a battle starting.
Use Case(s)
- To communicate battle initialization notice.
Message Format(s)
- |init|battle
Input Example(s)
- TODO
Message_join
Message containing info about a joining user.
ATTRIBUTE | DESCRIPTION |
---|---|
USERNAME |
The username of the joining player
TYPE:
|
Use Case(s)
- To communicate player room user entry.
Message Format(s)
- |join|USERNAME
Input Example(s)
- |j|☆colress-gpt-test1
Message_leave
Message containing info about a leaving user.
ATTRIBUTE | DESCRIPTION |
---|---|
USERNAME |
The username of the leaving player
TYPE:
|
Use Case(s)
- To communicate player room user exit.
Message Format(s)
- |leave|USERNAME
- |l|USERNAME
Input Example(s)
- |l|☆colress-gpt-test1
Message_pm
Message containing a PM to/from the user.
ATTRIBUTE | DESCRIPTION |
---|---|
SOURCE |
The username of the user who sent the pm
TYPE:
|
TARGET |
The username of the user who received the pm
TYPE:
|
PM |
The message. Newlines are denoted with |
TYPE:
|
IS_CHALLENGE |
Whether this PM is a challenge to a battle
TYPE:
|
CHALLENGE_FORMAT |
The format of the challenge if it is a challenge
TYPE:
|
Use Case(s)
- Notify the user about a PM received.
Message Format(s)
- |pm|SOURCE|TARGET|PM
Input Example(s)
- TODO
Message_title
Message notifying about the title of a room.
ATTRIBUTE | DESCRIPTION |
---|---|
TITLE |
The title of this match as shown on pokemon showdown
TYPE:
|
Use Case(s)
- To communicate room title info.
Message Format(s)
- |title|TITLE
Input Example(s)
- |title|colress-gpt-test1 vs. colress-gpt-test2
Message_updatechallenges
Message containing a current challenge searches, if any.
ATTRIBUTE | DESCRIPTION |
---|---|
OUTGOING |
A dictionary of username->format for each outgoing challenge
TYPE:
|
INCOMING |
A dictionary of username->format for each incoming challenge
TYPE:
|
Use Case(s)
- Gives the user an update about all of their current battle challenge requests.
Message Format(s)
- |updatechallenges|JSON
Input Example(s)
- TODO
Message_updatesearch
Message containing a current ladder searches, if any.
ATTRIBUTE | DESCRIPTION |
---|---|
SEARCHING |
A list of formats currently searching for a ladder match
TYPE:
|
GAMES |
A optional dictionary of game-id->format of currently ongoing games
TYPE:
|
Use Case(s)
- Gives the user an update about all of their current battle search requests.
Message Format(s)
- |updatesearch|JSON
Input Example(s)
- TODO
Message_updateuser
Message containing info about your user settings / login information.
ATTRIBUTE | DESCRIPTION |
---|---|
USERNAME |
The username of your current login
TYPE:
|
NAMED |
Whether you are currently logged in or not
TYPE:
|
AVATAR |
Either a number id of the user's avatar or a custom value
TYPE:
|
SETTINGS |
The user settings for your current user session
TYPE:
|
Use Case(s)
- To communicate any changes to your login / user session.
Message Format(s)
- |updateuser|USER|NAMED|AVATAR|SETTINGS
Input Example(s)
- TODO
Message Utility Classes
Contains BaseModels for Message parsing and processing.
Remember to use Message.from_message directly, unless you are building test cases where you want to assert that
a given message leads to a certain subclass of Message. from_message
will auto-detect which MType the given
message corresponds to, and return the associated subclass (or an error detailing what went wrong) for you.
CustomGroup
A helper class to contain information about server custom groups.
MType
String-Enum for holding all unique categories of Showdown Generic Messages.
See https://github.com/smogon/pokemon-showdown/blob/master/PROTOCOL.md for the (partial) list of message types
UserSettings
A helper class to contain information about user settings.
Attributes:
Name | Type | Description |
---|---|---|
BLOCK_CHALLENGES |
bool
|
Whether you are currently blocking challenges |
BLOCK_PMS |
bool
|
Whether you are currently blocking PMs |
IGNORE_TICKETS |
bool
|
Whether you are currently ignoring tickets |
HIDE_BATTLES |
bool
|
Whether you are currently hiding battles on your trainer card |
BLOCK_INVITES |
bool
|
Whether you are currently blocking invites |
DO_NOT_DISTURB |
bool
|
Your current do not disturb setting |
BLOCK_FRIEND_REQUESTS |
bool
|
Whether you are currently blocking friend requests |
ALLOW_FRIEND_NOTIFICATIONS |
bool
|
Whether you are currently allowing friend notifications |
DISPLAY_BATTLES |
bool
|
Whether you are currently displaying battles to friends |
HIDE_LOGINS |
bool
|
Whether you are currently hiding logins |
HIDDEN_NEXT_BATTLE |
bool
|
Whether you are hiding your next battle or not |
INVITE_ONLY_NEXT_BATTLE |
bool
|
Whether you are limiting your next battle to invite only or not |
LANGUAGE |
Optional[str]
|
The language set by your user |