.. _moobius_core_sdk: ################################################################################### moobius.core.sdk ################################################################################### ****************************** Module-level functions ****************************** (No module-level functions) ************************************ Class Moobius ************************************ This is the main core class of Moobius. CCS services inherit this class. This is a big switchyard for handling HTTP, the Websocket, and sending callbacks back to the CCS app. This has a complex lifecycle with server initialization steps, etc. .. _moobius.core.sdk.Moobius.true_channel_list: Moobius.true_channel_list --------------------------------------------------------------------------------------------------------------------- Gets the list of channels the self will end up bound to. Only used if self.service_mode. .. raw:: html

Signature:

* **Moobius.true_channel_list**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* The channel id list. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.create_new_service: Moobius.create_new_service --------------------------------------------------------------------------------------------------------------------- Creates a new service and sets self.client_id to it.. .. raw:: html

Signature:

* **Moobius.create_new_service**(self, description) .. raw:: html

Parameters:

* __description='Generated by MoobiusService':__ N optional description. .. raw:: html

Returns:

* The service_id. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.start: Moobius.start --------------------------------------------------------------------------------------------------------------------- Starts the service and calls start() fns are called with wand.run. There are 6 steps: 1. Authenticate. 2. Connect to the websocket server. 3. Bind the service to the channels, if a service. If there is no service_id in the config file, create a new service and update the config file. 4. Start the scheduler and run refresh(), authenticate(), and send_heartbeat() periodically. 5. Call the on_start() callback (override this method to perform your own initialization tasks). 6. Start listening to the websocket and the Wand. .. raw:: html

Signature:

* **Moobius.start**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.user_join_service_channels: Moobius.user_join_service_channels --------------------------------------------------------------------------------------------------------------------- Joins service channels given a service config dict or JSON filename (use in user mode). .. raw:: html

Signature:

* **Moobius.user_join_service_channels**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.fetch_service_id_each_channel: Moobius.fetch_service_id_each_channel --------------------------------------------------------------------------------------------------------------------- .. raw:: html

Signature:

* **Moobius.fetch_service_id_each_channel**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* The dict describing which service_id each channel_id is bound to. Channels can only be bound to a single service. Channels not bound to any service will not be in the dict. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.fetch_bound_channels: Moobius.fetch_bound_channels --------------------------------------------------------------------------------------------------------------------- .. raw:: html

Signature:

* **Moobius.fetch_bound_channels**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* The list of channels that are bound to this service. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.fetch_characters: Moobius.fetch_characters --------------------------------------------------------------------------------------------------------------------- .. raw:: html

Signature:

* **Moobius.fetch_characters**(self, channel_id) .. raw:: html

Parameters:

* __channel_id:__ Channel id. .. raw:: html

Returns:

* The list of Character objects. This list includes: Real members (ids for a particular user-channel combination) who joined the channel with the given channel_id. Agent characters that have been created by this service; agent characters are not bound to any channel. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.send_message: Moobius.send_message --------------------------------------------------------------------------------------------------------------------- Sends a message down (or up if in user-mode). This function is very flexible. .. raw:: html

Signature:

* **Moobius.send_message**(self, message, channel_id, sender, recipients, subtype, text, path, image, audio, link, title, button, len_limit, file_display_name, context) .. raw:: html

Parameters:

* __message:__ The message to send. If a string, the message will be a text message unless subtype is set. If not a text message, the string must either be a local file_path or an http(s) file_path. If a MessageBody or dict, the message sent will depend on it's fields/attributes as well as the overrides specified. If a pathlib.Path, will be a file/audio/image message by default. * __channel_id=None:__ The channel ids, if None message must be a MessageBody with the channel_id. Overrides message if not None. * __sender=None:__ The character/user who's avatar appears to "speak" this message. Overrides message if not None. * __recipients=None:__ List of characters or character_ids. Overrides message if not None. * __subtype=None:__ Can be set to types.TEXT, types.IMAGE, types.AUDIO, types.FILE, or types.CARD If None, the subtype will be inferred. * __text=None:__ Text which will override message. * __path=None:__ The filepath or URL of the message's content. Not needed for text messages. * __image=None:__ Equivalent to path except for also setting the subtype to types.IMAGE. * __audio=None:__ Equivalent to path except for also setting the subtype to types.AUDIO. * __link=None:__ For card messages, the URL that the link links to. * __title=None:__ For card messages, the card title. * __button=None:__ For card messages, the text that appears in the button. * __len_limit=None:__ Limit the length of large text messages. * __file_display_name=None:__ The name shown for downloadable files can be set to a value different than the filename. Sets the subtype to "types.FILE" if subtype is not specified. * __context=None:__ Optional metadata. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. raw:: html

Example:

TODO many examples! .. _moobius.core.sdk.Moobius.send: Moobius.send --------------------------------------------------------------------------------------------------------------------- Sends any kind of payload to the websocket. Example payload types: message_down, update, update_characters, update_canvas, update_buttons, update_style, and heartbeat. Rarely used except internally, but provides the most flexibility for those special occasions. .. raw:: html

Signature:

* **Moobius.send**(self, payload_type, payload_body) .. raw:: html

Parameters:

* __payload_type:__ The type of the payload. * __payload_body:__ The body of the payload. Strings will be converted into a Payload object. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.create_channel: Moobius.create_channel --------------------------------------------------------------------------------------------------------------------- Creates a channel. By default bind is True, which means the service connects itself to the channel. .. raw:: html

Signature:

* **Moobius.create_channel**(self, channel_name, channel_desc, bind) .. raw:: html

Parameters:

* __channel_name:__ Channel name. * __channel_desc:__ The channel description. * __bind=True:__ Whether to bind to the new channel. .. raw:: html

Returns:

* The channel id. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.send_canvas: Moobius.send_canvas --------------------------------------------------------------------------------------------------------------------- Updates the canvas. .. raw:: html

Signature:

* **Moobius.send_canvas**(self, canvas_items, channel_id, recipients) .. raw:: html

Parameters:

* __canvas_items:__ List of CanvasItems (which have text and/or images). * __channel_id:__ A channel_id. * __recipients:__ The recipients. .. raw:: html

Returns:

* The message. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.send_heartbeat: Moobius.send_heartbeat --------------------------------------------------------------------------------------------------------------------- Sends a heartbeat to the server. .. raw:: html

Signature:

* **Moobius.send_heartbeat**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.send_refresh: Moobius.send_refresh --------------------------------------------------------------------------------------------------------------------- Sends a refresh. .. raw:: html

Signature:

* **Moobius.send_refresh**(self, channel_id) .. raw:: html

Parameters:

* __channel_id:__ Channel_id. .. raw:: html

Returns:

* The message sent. A user function. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.do_member_sync: Moobius.do_member_sync --------------------------------------------------------------------------------------------------------------------- Syncs a member.. This is the most common way to send buttons, etc. .. raw:: html

Signature:

* **Moobius.do_member_sync**(self, channel_id, character) .. raw:: html

Parameters:

* __channel_id:__ Channel_id. * __character:__ Character/character_id. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.before_channel_init: Moobius.before_channel_init --------------------------------------------------------------------------------------------------------------------- A global init called right before the channels are initialized. .. raw:: html

Signature:

* **Moobius.before_channel_init**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_channel_checkin: Moobius.on_channel_checkin --------------------------------------------------------------------------------------------------------------------- CCS apps often override this, syncing members, etc.. .. raw:: html

Signature:

* **Moobius.on_channel_checkin**(self, channel_id) .. raw:: html

Parameters:

* __channel_id:__ Channel id. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.send_service_login: Moobius.send_service_login --------------------------------------------------------------------------------------------------------------------- Logs in. Much like the HTTP api, this needs to be sent before any other messages. Fills in: the id of this service; the https token the service has for authentication; set to False. .. raw:: html

Signature:

* **Moobius.send_service_login**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* The message as a dict. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.refresh_authentication: Moobius.refresh_authentication --------------------------------------------------------------------------------------------------------------------- Refreshes the access token. .. raw:: html

Signature:

* **Moobius.refresh_authentication**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* The new token. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.authenticate: Moobius.authenticate --------------------------------------------------------------------------------------------------------------------- Authenticates using self.username andself.password. Needs to be called before any other API calls. .. raw:: html

Signature:

* **Moobius.authenticate**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* (the access token, the refresh token). Raises an Exception if doesn't receive a valid response. Like most GET and POST functions it will raise any errors thrown by the http API. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.sign_up: Moobius.sign_up --------------------------------------------------------------------------------------------------------------------- Signs up and sends the confirmation code to the email. After confirming the account, self.authenticate() can be used to retrieve access and refresh tokens. .. raw:: html

Signature:

* **Moobius.sign_up**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.sign_out: Moobius.sign_out --------------------------------------------------------------------------------------------------------------------- Signs out using the access token obtained from signing in. .. raw:: html

Signature:

* **Moobius.sign_out**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.update_current_user: Moobius.update_current_user --------------------------------------------------------------------------------------------------------------------- Updates the user info. Used by user mode. .. raw:: html

Signature:

* **Moobius.update_current_user**(self, avatar, description, name) .. raw:: html

Parameters:

* __avatar:__ Link to image or local file_path to upload. * __description:__ Of the user. * __name:__ The name that shows in chat. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.update_agent: Moobius.update_agent --------------------------------------------------------------------------------------------------------------------- Updates the characters name, avatar, etc for a FAKE user, for real users use update_current_user. Fills in: the id of this service. .. raw:: html

Signature:

* **Moobius.update_agent**(self, character, avatar, description, name) .. raw:: html

Parameters:

* __character:__ Who to update. Can also be a Character object or character_id. Cannot be a list. * __avatar:__ A link to user's image or a local file_path to upload. * __description:__ The description of user. * __name:__ The name that will show in chat. .. raw:: html

Returns:

* The Data about the user as a dict. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.update_channel: Moobius.update_channel --------------------------------------------------------------------------------------------------------------------- Updates the name and desc of a channel. .. raw:: html

Signature:

* **Moobius.update_channel**(self, channel_id, channel_name, channel_desc) .. raw:: html

Parameters:

* __channel_id:__ Which channel to update. * __channel_name:__ The new channel name. * __channel_desc:__ The new channel description. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.bind_service_to_channel: Moobius.bind_service_to_channel --------------------------------------------------------------------------------------------------------------------- Binds a service to a channel. This function is unusual in that it. Fills in: the id of this service. .. raw:: html

Signature:

* **Moobius.bind_service_to_channel**(self, channel_id) .. raw:: html

Parameters:

* __channel_id:__ Channel IDs. .. raw:: html

Returns:

* Whether it was sucessful rather than raising errors if it fails. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.unbind_service_from_channel: Moobius.unbind_service_from_channel --------------------------------------------------------------------------------------------------------------------- Unbinds a service to a channel. Fills in: the id of this service. .. raw:: html

Signature:

* **Moobius.unbind_service_from_channel**(self, channel_id) .. raw:: html

Parameters:

* __channel_id:__ Channel IDs. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.create_agent: Moobius.create_agent --------------------------------------------------------------------------------------------------------------------- Creates a character with a given name, avatar, and description. The created user will be bound to the given service. Fills in: the id of this service. .. raw:: html

Signature:

* **Moobius.create_agent**(self, name, avatar, description) .. raw:: html

Parameters:

* __name:__ The name of the user. * __avatar=None:__ The image URL of the user's picture OR a local file path. * __description='No description':__ The description of the user. .. raw:: html

Returns:

* The Character object representing the created user. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.fetch_popular_channels: Moobius.fetch_popular_channels --------------------------------------------------------------------------------------------------------------------- Fetches the popular channels,. .. raw:: html

Signature:

* **Moobius.fetch_popular_channels**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* The list of channel_id strings. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.fetch_channel_list: Moobius.fetch_channel_list --------------------------------------------------------------------------------------------------------------------- Fetches all? channels,. .. raw:: html

Signature:

* **Moobius.fetch_channel_list**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* The list of channel_id strings. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.fetch_member_ids: Moobius.fetch_member_ids --------------------------------------------------------------------------------------------------------------------- Fetches the member ids of a channel which coorespond to real users. Fills in: the id of this service. .. raw:: html

Signature:

* **Moobius.fetch_member_ids**(self, channel_id, raise_empty_list_err) .. raw:: html

Parameters:

* __channel_id:__ The channel ID. * __raise_empty_list_err=False:__ Raises an Exception if the list is empty. .. raw:: html

Returns:

* The list of character_id strings. .. raw:: html

Raises:

* An Exception (empty list) if raise_empty_list_err is True and the list is empty. .. _moobius.core.sdk.Moobius.fetch_character_profile: Moobius.fetch_character_profile --------------------------------------------------------------------------------------------------------------------- .. raw:: html

Signature:

* **Moobius.fetch_character_profile**(self, character) .. raw:: html

Parameters:

* __character:__ String-valued (or list-valued) character_id/character. .. raw:: html

Returns:

* The Character object (or list therof). It works for both member_ids and agent_ids. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.fetch_service_id_list: Moobius.fetch_service_id_list --------------------------------------------------------------------------------------------------------------------- .. raw:: html

Signature:

* **Moobius.fetch_service_id_list**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* The list of service_id strings of the user. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.fetch_agents: Moobius.fetch_agents --------------------------------------------------------------------------------------------------------------------- Fills in: the id of this service. .. raw:: html

Signature:

* **Moobius.fetch_agents**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* The list of non-user Character objects bound to this service. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.fetch_message_history: Moobius.fetch_message_history --------------------------------------------------------------------------------------------------------------------- Returns the message chat history. .. raw:: html

Signature:

* **Moobius.fetch_message_history**(self, channel_id, limit, before) .. raw:: html

Parameters:

* __channel_id:__ Channel with the messages inside of it. * __limit=1024:__ Max number of messages to return (messages further back in time, if any, will not be returned). * __before='null':__ Only return messages older than this. .. raw:: html

Returns:

* The list of dicts. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.upload: Moobius.upload --------------------------------------------------------------------------------------------------------------------- Uploads the file at local path file_path to the Moobius server. Automatically calculates the upload URL and upload fields. .. raw:: html

Signature:

* **Moobius.upload**(self, file_path) .. raw:: html

Parameters:

* __file_path:__ File_path. .. raw:: html

Returns:

* The uploaded URL. Raises an Exception if the upload fails. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.download: Moobius.download --------------------------------------------------------------------------------------------------------------------- Downloads a file from a url or other source to a local filename, automatically creating dirs if need be. .. raw:: html

Signature:

* **Moobius.download**(self, source, file_path, auto_dir, overwrite, bytes, headers) .. raw:: html

Parameters:

* __source:__ The url to download the file from. OR a MessageBody which has a .content.path in it. * __file_path=None:__ The file_path to download to. None will create a file based on the timestamp + random numbers. If no extension is specified, will infer the extension from the url if one exists. * __auto_dir=None:__ If no file_path is specified, a folder must be choosen. Defaults to './downloads'. * __overwrite=True:__ Allow overwriting pre-existing files. If False, will raise an Exception on name collision. * __bytes=False:__ If True, will return bytes instead of saving a file. * __headers=None:__ Optional headers. Use these for downloads that require auth. Can set to "self" to use the same auth headers that this instance is using. .. raw:: html

Returns:

* The full filepath if bytes if false, otherwise the file's content bytes if bytes=True. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.create_channel_group: Moobius.create_channel_group --------------------------------------------------------------------------------------------------------------------- Creates a channel group. .. raw:: html

Signature:

* **Moobius.create_channel_group**(self, channel_id, group_name, characters) .. raw:: html

Parameters:

* __channel_id:__ The id of the group leader?. * __group_name:__ What to call it. * __characters:__ A list of characters or character_id strings that will be inside the group. .. raw:: html

Returns:

* The group_id string. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.create_service_group: Moobius.create_service_group --------------------------------------------------------------------------------------------------------------------- Creates a group containing the list of characters_ids and returns this Group object. This group can then be used in send_message_down payloads. .. raw:: html

Signature:

* **Moobius.create_service_group**(self, characters) .. raw:: html

Parameters:

* __characters:__ A list of character_id strings or Characters that will be inside the group. .. raw:: html

Returns:

* The Group object. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.character_ids_of_channel_group: Moobius.character_ids_of_channel_group --------------------------------------------------------------------------------------------------------------------- Gets a list of character ids belonging to a channel group. Websocket payloads contain these channel_groups which are shorthand for a list of characters. .. raw:: html

Signature:

* **Moobius.character_ids_of_channel_group**(self, sender_id, channel_id, group_id) .. raw:: html

Parameters:

* __sender_id:__ The message's sender. * __channel_id:__ The message specified that it was sent in this channel. * __group_id:__ The messages recipients. .. raw:: html

Returns:

* The character_id list. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.character_ids_of_service_group: Moobius.character_ids_of_service_group --------------------------------------------------------------------------------------------------------------------- .. raw:: html

Signature:

* **Moobius.character_ids_of_service_group**(self, group_id) .. raw:: html

Parameters:

* __group_id:__ Group_id. .. raw:: html

Returns:

* The list of character ids belonging to a service group. Note that the 'recipients' in 'on message up' might be None: To avoid requiring checks for None this function will return an empty list given Falsey inputs or Falsey string literals. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.fetch_channel_temp_group: Moobius.fetch_channel_temp_group --------------------------------------------------------------------------------------------------------------------- Like fetch_channel_group_list but for TEMP groups.. Fills in: the id of this service. .. raw:: html

Signature:

* **Moobius.fetch_channel_temp_group**(self, channel_id) .. raw:: html

Parameters:

* __channel_id:__ Channel_id. .. raw:: html

Returns:

* The list of groups. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.fetch_channel_group_list: Moobius.fetch_channel_group_list --------------------------------------------------------------------------------------------------------------------- Similar to fetch_channel_group_dict.. Fills in: the id of this service. .. raw:: html

Signature:

* **Moobius.fetch_channel_group_list**(self, channel_id) .. raw:: html

Parameters:

* __channel_id:__ Channel_id. .. raw:: html

Returns:

* The raw data. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.fetch_user_from_group: Moobius.fetch_user_from_group --------------------------------------------------------------------------------------------------------------------- Not yet implemented! Fetches the user profile of a user from a group. .. raw:: html

Signature:

* **Moobius.fetch_user_from_group**(self, user_id, channel_id, group_id) .. raw:: html

Parameters:

* __user_id:__ The user ID. * __channel_id:__ The channel ID. (TODO: of what?). * __group_id:__ The group ID. .. raw:: html

Returns:

* The user profile Character object. .. raw:: html

Raises:

* An Exception because it is unused, unimplemented, and may be removed. .. _moobius.core.sdk.Moobius.fetch_target_group: Moobius.fetch_target_group --------------------------------------------------------------------------------------------------------------------- Not yet implemented! Fetches info about the group. .. raw:: html

Signature:

* **Moobius.fetch_target_group**(self, user_id, channel_id, group_id) .. raw:: html

Parameters:

* __user_id:__ The user id of the user bieng fetched (is this needed?). * __channel_id:__ The channel_id of the channel bieng fetched. * __group_id:__ Which group to fetch. .. raw:: html

Returns:

* The data-dict data. .. raw:: html

Raises:

* An Exception because it is unused, unimplemented, and may be removed. .. _moobius.core.sdk.Moobius.send_user_login: Moobius.send_user_login --------------------------------------------------------------------------------------------------------------------- Logs-in a user. Every 2h AWS will force-disconnect, so it is a good idea to send this on connect. Fills in: the https token the service has for authentication; set to False. .. raw:: html

Signature:

* **Moobius.send_user_login**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* The message as a dict. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.send_update: Moobius.send_update --------------------------------------------------------------------------------------------------------------------- A generic update function that is rarely used. Fills in: the id of this service; set to False. .. raw:: html

Signature:

* **Moobius.send_update**(self, data, target_client_id) .. raw:: html

Parameters:

* __data:__ The content of the update. * __target_client_id:__ The target client id (TODO: not currently used). .. raw:: html

Returns:

* The message as a dict. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.send_characters: Moobius.send_characters --------------------------------------------------------------------------------------------------------------------- Updates the characters that the recipients see. Fills in: the id of this service; set to False. .. raw:: html

Signature:

* **Moobius.send_characters**(self, characters, channel_id, recipients) .. raw:: html

Parameters:

* __characters:__ The group id to represent the characters who are updated. * __channel_id:__ The channel id. * __recipients:__ The group id to send to. .. raw:: html

Returns:

* The message as a dict. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.send_buttons: Moobius.send_buttons --------------------------------------------------------------------------------------------------------------------- Updates the buttons that the recipients see. Fills in: the id of this service; set to False. .. raw:: html

Signature:

* **Moobius.send_buttons**(self, buttons, channel_id, recipients) .. raw:: html

Parameters:

* __buttons:__ The buttons list to be updated. * __channel_id:__ The channel id. * __recipients:__ The group id to send to. .. raw:: html

Returns:

* The message as a dict. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. raw:: html

Example:

>>> continue_button = >>> {"button_name": "Continue Playing", "button_id": "play", >>> "button_name": "Continue Playing", "new_window": False, >>> "arguments": []} >>> ws_client.update_buttons("service_id", "channel_id", [continue_button], ["user1", "user2"]) .. _moobius.core.sdk.Moobius.send_menu: Moobius.send_menu --------------------------------------------------------------------------------------------------------------------- Updates the right-click menu that the recipients can open on various messages. Fills in: the id of this service; set to False. .. raw:: html

Signature:

* **Moobius.send_menu**(self, menu_items, channel_id, recipients) .. raw:: html

Parameters:

* __menu_items:__ List of MenuItem dataclasses. * __channel_id:__ The channel id. * __recipients:__ The group id to send the changes to. .. raw:: html

Returns:

* The message as a dict. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.send_style: Moobius.send_style --------------------------------------------------------------------------------------------------------------------- Updates the style (whether the canvas is expanded, other look-and-feel aspects) that the recipients see. Fills in: the id of this service; set to False. .. raw:: html

Signature:

* **Moobius.send_style**(self, style_items, channel_id, recipients) .. raw:: html

Parameters:

* __style_items:__ The style content to be updated. Dicts are converted into 1-elemnt lists. * __channel_id:__ The channel id. * __recipients:__ The group id to send to. .. raw:: html

Returns:

* The message as a dict. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. raw:: html

Example:

>>> style_items = [ >>> { >>> "widget": "channel", >>> "display": "invisible", >>> }, >>> { >>> "widget": "button", >>> "display": "highlight", >>> "button_hook": { >>> "button_id": "button_id", >>> "button_name": "done", >>> "arguments": [] >>> }, >>> "text": "

Start from here.

This is a Button, which most channels have

" >>> }] >>> ws_client.update_style("service_id", "channel_id", style_items, ["user1", "user2"]) .. _moobius.core.sdk.Moobius.send_join_channel: Moobius.send_join_channel --------------------------------------------------------------------------------------------------------------------- A user joins the channel with channel_id, unless dry_run is True.. Fills in: the id of this service when in user mode, which is a user id; set to False. .. raw:: html

Signature:

* **Moobius.send_join_channel**(self, channel_id) .. raw:: html

Parameters:

* __channel_id:__ The channel_id. .. raw:: html

Returns:

* The message sent. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.send_leave_channel: Moobius.send_leave_channel --------------------------------------------------------------------------------------------------------------------- A user leaves the channel with channel_id, unless dry_run is True.. Fills in: the id of this service when in user mode, which is a user id; set to False. .. raw:: html

Signature:

* **Moobius.send_leave_channel**(self, channel_id) .. raw:: html

Parameters:

* __channel_id:__ The channel_id. .. raw:: html

Returns:

* The message sent. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.send_button_click: Moobius.send_button_click --------------------------------------------------------------------------------------------------------------------- Sends a button click as a user. Fills in: the id of this service when in user mode, which is a user id; set to False. .. raw:: html

Signature:

* **Moobius.send_button_click**(self, button_id, bottom_button_id, button_args, channel_id) .. raw:: html

Parameters:

* __button_id:__ The button's ID. * __bottom_button_id:__ The bottom button, set to "confirm" if there is no bottom button. * __button_args:__ What arguments (if any) were selected on the button (use an empty list of there are none). * __channel_id:__ The id of the channel the user pressed the button in. .. raw:: html

Returns:

* The message sent as a dict. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.send_menu_item_click: Moobius.send_menu_item_click --------------------------------------------------------------------------------------------------------------------- Sends a menu item click as a user. Fills in: the id of this service when in user mode, which is a user id; set to False. .. raw:: html

Signature:

* **Moobius.send_menu_item_click**(self, menu_item_id, bottom_button_id, button_args, the_message, channel_id) .. raw:: html

Parameters:

* __menu_item_id:__ The menu item's ID. * __bottom_button_id:__ The bottom button, set to "confirm" if there is no bottom button. * __button_args:__ What arguments (if any) were selected on the menu item's dialog (use an empty list of there are none). * __the_message:__ Can be a string-valued message_id, or a full message body. If a full message the subtype and content will be filled in. * __channel_id:__ The id of the channel the user pressed the button in. .. raw:: html

Returns:

* The message sent as a dict. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.listen_loop: Moobius.listen_loop --------------------------------------------------------------------------------------------------------------------- Listens to the wand in an infinite loop, polling self.queue (which is an aioprocessing.AioQueue). This allows the wand to send "spells" (messages) to the services at any time. .. raw:: html

Signature:

* **Moobius.listen_loop**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* The Never. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.handle_received_payload: Moobius.handle_received_payload --------------------------------------------------------------------------------------------------------------------- Decodes the received websocket payload JSON and calls the handler based on p['type'],. Example methods called: on_message_up(), on_action(), on_button_click(), on_copy_client(), on_unknown_payload() Example use-case: >>> self.ws_client = WSClient(ws_server_uri, on_connect=self.send_service_login, handle=self.handle_received_payload). .. raw:: html

Signature:

* **Moobius.handle_received_payload**(self, payload) .. raw:: html

Parameters:

* __payload:__ Payload string. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_action: Moobius.on_action --------------------------------------------------------------------------------------------------------------------- Calls the corresponding method to handle different subtypes of action. This callback is rarely overriden; it is more common to override the other callbacks that the calls. Example methods called: on_button_click(), on_join(). .. raw:: html

Signature:

* **Moobius.on_action**(self, action_data) .. raw:: html

Parameters:

* __action_data:__ Action data (as a dict) from a user. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_update: Moobius.on_update --------------------------------------------------------------------------------------------------------------------- Dispatches it to one of various callbacks. Use for user mode. It is recommended to overload the invididual callbacks instead of this function. .. raw:: html

Signature:

* **Moobius.on_update**(self, update) .. raw:: html

Parameters:

* __update:__ N Update object from the socket. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_start: Moobius.on_start --------------------------------------------------------------------------------------------------------------------- Called when the service is initialized. .. raw:: html

Signature:

* **Moobius.on_start**(self) .. raw:: html

Parameters:

* __(this class constructor accepts no arguments):__ .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_channel_init: Moobius.on_channel_init --------------------------------------------------------------------------------------------------------------------- Called once per channel on startup.. By default, if the db has been set, a MoobiusStorage is created in self.channels, otherwise it is set to None. Also does a channel sync by default. .. raw:: html

Signature:

* **Moobius.on_channel_init**(self, channel_id) .. raw:: html

Parameters:

* __channel_id:__ Channel ID. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_spell: Moobius.on_spell --------------------------------------------------------------------------------------------------------------------- Called when a "spell" from the wand is received, which can be any object but is often a string.. .. raw:: html

Signature:

* **Moobius.on_spell**(self, obj) .. raw:: html

Parameters:

* __obj:__ The wand sent this process. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_message_up: Moobius.on_message_up --------------------------------------------------------------------------------------------------------------------- Example MessageBody object: >>> moobius.MessageBody(subtype="text", channel_id=, content=MessageContent(...), timestamp=1707254706635, >>> recipients=[, ], sender=, message_id=, >>> context={'group_id': , 'channel_type': 'ccs'}). .. raw:: html

Signature:

* **Moobius.on_message_up**(self, message) .. raw:: html

Parameters:

* __message:__ A message from a user. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_copy_client: Moobius.on_copy_client --------------------------------------------------------------------------------------------------------------------- Example Copy object: >>> moobius.Copy(request_id=, origin_type=message_down, status=True, context={'message': 'Message received'}). .. raw:: html

Signature:

* **Moobius.on_copy_client**(self, copy) .. raw:: html

Parameters:

* __copy:__ A "Copy" request from the user. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_refresh: Moobius.on_refresh --------------------------------------------------------------------------------------------------------------------- .. raw:: html

Signature:

* **Moobius.on_refresh**(self, action) .. raw:: html

Parameters:

* __action:__ A "Copy" request from the user. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_join: Moobius.on_join --------------------------------------------------------------------------------------------------------------------- This callback happens when the user joins a channel.. Commonly used to inform everyone about this new user and update everyone's character list. .. raw:: html

Signature:

* **Moobius.on_join**(self, action) .. raw:: html

Parameters:

* __action:__ Channel and member id. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_leave: Moobius.on_leave --------------------------------------------------------------------------------------------------------------------- Called when the user leaves a channel.. Commonly used to update everyone's character list. .. raw:: html

Signature:

* **Moobius.on_leave**(self, action) .. raw:: html

Parameters:

* __action:__ Channel and member id. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_button_click: Moobius.on_button_click --------------------------------------------------------------------------------------------------------------------- Handles a button click from a user.. Example ButtonClick object: >>> moobius.ButtonClick(button_id="the_big_red_button", channel_id=, sender=, components=[], context={}). .. raw:: html

Signature:

* **Moobius.on_button_click**(self, action) .. raw:: html

Parameters:

* __action:__ User's ButtonClick. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_menu_item_click: Moobius.on_menu_item_click --------------------------------------------------------------------------------------------------------------------- Handles a context menu right click from a user.. Example MenuItemClick object: >>> MenuItemClick(item_id=1, message_id=, message_subtypes=text, message_content={'text': 'Click on this message.'}, channel_id=, context={}, recipients=[]). .. raw:: html

Signature:

* **Moobius.on_menu_item_click**(self, action) .. raw:: html

Parameters:

* __action:__ User's MenuItemClick. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_unknown_payload: Moobius.on_unknown_payload --------------------------------------------------------------------------------------------------------------------- A catch-all for handling unknown payloads.. .. raw:: html

Signature:

* **Moobius.on_unknown_payload**(self, payload_data) .. raw:: html

Parameters:

* __payload_data:__ Payload-as-dict that has not been recognized by the other handlers and may not have a format listed in types. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_message_down: Moobius.on_message_down --------------------------------------------------------------------------------------------------------------------- Callback when the user recieves a message.. Use for user mode. .. raw:: html

Signature:

* **Moobius.on_message_down**(self, message) .. raw:: html

Parameters:

* __message:__ Service's MessageBody. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_update_characters: Moobius.on_update_characters --------------------------------------------------------------------------------------------------------------------- Callback when the user recieves the character list.. One of the multiple update callbacks. Use for user mode. .. raw:: html

Signature:

* **Moobius.on_update_characters**(self, update) .. raw:: html

Parameters:

* __update:__ Service's Update. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_update_channel_info: Moobius.on_update_channel_info --------------------------------------------------------------------------------------------------------------------- Callback when the user recieves the channel info.. One of the multiple update callbacks. Use for user mode. .. raw:: html

Signature:

* **Moobius.on_update_channel_info**(self, update) .. raw:: html

Parameters:

* __update:__ Service's Update. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_update_canvas: Moobius.on_update_canvas --------------------------------------------------------------------------------------------------------------------- Callback when the user recieves the canvas content.. One of the multiple update callbacks. Use for user mode. .. raw:: html

Signature:

* **Moobius.on_update_canvas**(self, update) .. raw:: html

Parameters:

* __update:__ Service's Update. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_update_buttons: Moobius.on_update_buttons --------------------------------------------------------------------------------------------------------------------- Callback when the user recieves the buttons.. One of the multiple update callbacks. Use for user mode. .. raw:: html

Signature:

* **Moobius.on_update_buttons**(self, update) .. raw:: html

Parameters:

* __update:__ Service's Update. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_update_style: Moobius.on_update_style --------------------------------------------------------------------------------------------------------------------- Callback when the user recieves the style info (look and feel).. One of the multiple update callbacks. Use for user mode. .. raw:: html

Signature:

* **Moobius.on_update_style**(self, update) .. raw:: html

Parameters:

* __update:__ Service's Update. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) .. _moobius.core.sdk.Moobius.on_update_menu: Moobius.on_update_menu --------------------------------------------------------------------------------------------------------------------- Callback when the user recieves the context menu info.. One of the multiple update callbacks. Use for user mode. .. raw:: html

Signature:

* **Moobius.on_update_menu**(self, update) .. raw:: html

Parameters:

* __update:__ Service's Update. .. raw:: html

Returns:

* None. .. raw:: html

Raises:

* (this function does not raise any notable errors) Class attributes -------------------- ********************** Internals ********************** .. toctree:: :maxdepth: 2 moobius.core.sdk_internal_attrs