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.true_channel_list#

Gets the list of channels the self will end up bound to. Only used if self.service_mode.

Signature:

  • **Moobius.true_channel_list**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • The channel id list.

Raises:

  • (this function does not raise any notable errors)

Moobius.create_new_service#

Creates a new service and sets self.client_id to it..

Signature:

  • **Moobius.create_new_service**(self, description)

Parameters:

  • __description=’Generated by MoobiusService’:__ N optional description.

Returns:

  • The service_id.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.start**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.user_join_service_channels#

Joins service channels given a service config dict or JSON filename (use in user mode).

Signature:

  • **Moobius.user_join_service_channels**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.fetch_service_id_each_channel#

Signature:

  • **Moobius.fetch_service_id_each_channel**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

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.

Raises:

  • (this function does not raise any notable errors)

Moobius.fetch_bound_channels#

Signature:

  • **Moobius.fetch_bound_channels**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • The list of channels that are bound to this service.

Raises:

  • (this function does not raise any notable errors)

Moobius.fetch_characters#

Signature:

  • **Moobius.fetch_characters**(self, channel_id)

Parameters:

  • __channel_id:__ Channel id.

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.

Raises:

  • (this function does not raise any notable errors)

Moobius.send_message#

Sends a message down (or up if in user-mode). This function is very flexible.

Signature:

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

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.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Example:

TODO many examples!

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.

Signature:

  • **Moobius.send**(self, payload_type, payload_body)

Parameters:

  • __payload_type:__ The type of the payload.

  • __payload_body:__ The body of the payload.

    Strings will be converted into a Payload object.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.create_channel#

Creates a channel. By default bind is True, which means the service connects itself to the channel.

Signature:

  • **Moobius.create_channel**(self, channel_name, channel_desc, bind)

Parameters:

  • __channel_name:__ Channel name.

  • __channel_desc:__ The channel description.

  • __bind=True:__ Whether to bind to the new channel.

Returns:

  • The channel id.

Raises:

  • (this function does not raise any notable errors)

Moobius.send_canvas#

Updates the canvas.

Signature:

  • **Moobius.send_canvas**(self, canvas_items, channel_id, recipients)

Parameters:

  • __canvas_items:__ List of CanvasItems (which have text and/or images).

  • __channel_id:__ A channel_id.

  • __recipients:__ The recipients.

Returns:

  • The message.

Raises:

  • (this function does not raise any notable errors)

Moobius.send_heartbeat#

Sends a heartbeat to the server.

Signature:

  • **Moobius.send_heartbeat**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.send_refresh#

Sends a refresh.

Signature:

  • **Moobius.send_refresh**(self, channel_id)

Parameters:

  • __channel_id:__ Channel_id.

Returns:

  • The message sent. A user function.

Raises:

  • (this function does not raise any notable errors)

Moobius.do_member_sync#

Syncs a member.. This is the most common way to send buttons, etc.

Signature:

  • **Moobius.do_member_sync**(self, channel_id, character)

Parameters:

  • __channel_id:__ Channel_id.

  • __character:__ Character/character_id.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.before_channel_init#

A global init called right before the channels are initialized.

Signature:

  • **Moobius.before_channel_init**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_channel_checkin#

CCS apps often override this, syncing members, etc..

Signature:

  • **Moobius.on_channel_checkin**(self, channel_id)

Parameters:

  • __channel_id:__ Channel id.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.send_service_login**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • The message as a dict.

Raises:

  • (this function does not raise any notable errors)

Moobius.refresh_authentication#

Refreshes the access token.

Signature:

  • **Moobius.refresh_authentication**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • The new token.

Raises:

  • (this function does not raise any notable errors)

Moobius.authenticate#

Authenticates using self.username andself.password. Needs to be called before any other API calls.

Signature:

  • **Moobius.authenticate**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

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.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.sign_up**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.sign_out#

Signs out using the access token obtained from signing in.

Signature:

  • **Moobius.sign_out**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.update_current_user#

Updates the user info. Used by user mode.

Signature:

  • **Moobius.update_current_user**(self, avatar, description, name)

Parameters:

  • __avatar:__ Link to image or local file_path to upload.

  • __description:__ Of the user.

  • __name:__ The name that shows in chat.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.update_agent**(self, character, avatar, description, name)

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.

Returns:

  • The Data about the user as a dict.

Raises:

  • (this function does not raise any notable errors)

Moobius.update_channel#

Updates the name and desc of a channel.

Signature:

  • **Moobius.update_channel**(self, channel_id, channel_name, channel_desc)

Parameters:

  • __channel_id:__ Which channel to update.

  • __channel_name:__ The new channel name.

  • __channel_desc:__ The new channel description.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.bind_service_to_channel**(self, channel_id)

Parameters:

  • __channel_id:__ Channel IDs.

Returns:

  • Whether it was sucessful rather than raising errors if it fails.

Raises:

  • (this function does not raise any notable errors)

Moobius.unbind_service_from_channel#

Unbinds a service to a channel. Fills in: the id of this service.

Signature:

  • **Moobius.unbind_service_from_channel**(self, channel_id)

Parameters:

  • __channel_id:__ Channel IDs.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.create_agent**(self, name, avatar, description)

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.

Returns:

  • The Character object representing the created user.

Raises:

  • (this function does not raise any notable errors)

Moobius.fetch_channel_list#

Fetches all? channels,.

Signature:

  • **Moobius.fetch_channel_list**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • The list of channel_id strings.

Raises:

  • (this function does not raise any notable errors)

Moobius.fetch_member_ids#

Fetches the member ids of a channel which coorespond to real users. Fills in: the id of this service.

Signature:

  • **Moobius.fetch_member_ids**(self, channel_id, raise_empty_list_err)

Parameters:

  • __channel_id:__ The channel ID.

  • __raise_empty_list_err=False:__ Raises an Exception if the list is empty.

Returns:

  • The list of character_id strings.

Raises:

  • An Exception (empty list) if raise_empty_list_err is True and the list is empty.

Moobius.fetch_character_profile#

Signature:

  • **Moobius.fetch_character_profile**(self, character)

Parameters:

  • __character:__ String-valued (or list-valued) character_id/character.

Returns:

  • The Character object (or list therof).

It works for both member_ids and agent_ids.

Raises:

  • (this function does not raise any notable errors)

Moobius.fetch_service_id_list#

Signature:

  • **Moobius.fetch_service_id_list**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • The list of service_id strings of the user.

Raises:

  • (this function does not raise any notable errors)

Moobius.fetch_agents#

Fills in: the id of this service.

Signature:

  • **Moobius.fetch_agents**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • The list of non-user Character objects bound to this service.

Raises:

  • (this function does not raise any notable errors)

Moobius.fetch_message_history#

Returns the message chat history.

Signature:

  • **Moobius.fetch_message_history**(self, channel_id, limit, before)

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.

Returns:

  • The list of dicts.

Raises:

  • (this function does not raise any notable errors)

Moobius.upload#

Uploads the file at local path file_path to the Moobius server. Automatically calculates the upload URL and upload fields.

Signature:

  • **Moobius.upload**(self, file_path)

Parameters:

  • __file_path:__ File_path.

Returns:

  • The uploaded URL. Raises an Exception if the upload fails.

Raises:

  • (this function does not raise any notable errors)

Moobius.download#

Downloads a file from a url or other source to a local filename, automatically creating dirs if need be.

Signature:

  • **Moobius.download**(self, source, file_path, auto_dir, overwrite, bytes, headers)

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.

Returns:

  • The full filepath if bytes if false, otherwise the file’s content bytes if bytes=True.

Raises:

  • (this function does not raise any notable errors)

Moobius.create_channel_group#

Creates a channel group.

Signature:

  • **Moobius.create_channel_group**(self, channel_id, group_name, characters)

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.

Returns:

  • The group_id string.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.create_service_group**(self, characters)

Parameters:

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

Returns:

  • The Group object.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.character_ids_of_channel_group**(self, sender_id, channel_id, group_id)

Parameters:

  • __sender_id:__ The message’s sender.

  • __channel_id:__ The message specified that it was sent in this channel.

  • __group_id:__ The messages recipients.

Returns:

  • The character_id list.

Raises:

  • (this function does not raise any notable errors)

Moobius.character_ids_of_service_group#

Signature:

  • **Moobius.character_ids_of_service_group**(self, group_id)

Parameters:

  • __group_id:__ Group_id.

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.

Raises:

  • (this function does not raise any notable errors)

Moobius.fetch_channel_temp_group#

Like fetch_channel_group_list but for TEMP groups.. Fills in: the id of this service.

Signature:

  • **Moobius.fetch_channel_temp_group**(self, channel_id)

Parameters:

  • __channel_id:__ Channel_id.

Returns:

  • The list of groups.

Raises:

  • (this function does not raise any notable errors)

Moobius.fetch_channel_group_list#

Similar to fetch_channel_group_dict.. Fills in: the id of this service.

Signature:

  • **Moobius.fetch_channel_group_list**(self, channel_id)

Parameters:

  • __channel_id:__ Channel_id.

Returns:

  • The raw data.

Raises:

  • (this function does not raise any notable errors)

Moobius.fetch_user_from_group#

Not yet implemented! Fetches the user profile of a user from a group.

Signature:

  • **Moobius.fetch_user_from_group**(self, user_id, channel_id, group_id)

Parameters:

  • __user_id:__ The user ID.

  • __channel_id:__ The channel ID. (TODO: of what?).

  • __group_id:__ The group ID.

Returns:

  • The user profile Character object.

Raises:

  • An Exception because it is unused, unimplemented, and may be removed.

Moobius.fetch_target_group#

Not yet implemented! Fetches info about the group.

Signature:

  • **Moobius.fetch_target_group**(self, user_id, channel_id, group_id)

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.

Returns:

  • The data-dict data.

Raises:

  • An Exception because it is unused, unimplemented, and may be removed.

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.

Signature:

  • **Moobius.send_user_login**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • The message as a dict.

Raises:

  • (this function does not raise any notable errors)

Moobius.send_update#

A generic update function that is rarely used. Fills in: the id of this service; set to False.

Signature:

  • **Moobius.send_update**(self, data, target_client_id)

Parameters:

  • __data:__ The content of the update.

  • __target_client_id:__ The target client id (TODO: not currently used).

Returns:

  • The message as a dict.

Raises:

  • (this function does not raise any notable errors)

Moobius.send_characters#

Updates the characters that the recipients see. Fills in: the id of this service; set to False.

Signature:

  • **Moobius.send_characters**(self, characters, channel_id, recipients)

Parameters:

  • __characters:__ The group id to represent the characters who are updated.

  • __channel_id:__ The channel id.

  • __recipients:__ The group id to send to.

Returns:

  • The message as a dict.

Raises:

  • (this function does not raise any notable errors)

Moobius.send_buttons#

Updates the buttons that the recipients see. Fills in: the id of this service; set to False.

Signature:

  • **Moobius.send_buttons**(self, buttons, channel_id, recipients)

Parameters:

  • __buttons:__ The buttons list to be updated.

  • __channel_id:__ The channel id.

  • __recipients:__ The group id to send to.

Returns:

  • The message as a dict.

Raises:

  • (this function does not raise any notable errors)

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.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.

Signature:

  • **Moobius.send_menu**(self, menu_items, channel_id, recipients)

Parameters:

  • __menu_items:__ List of MenuItem dataclasses.

  • __channel_id:__ The channel id.

  • __recipients:__ The group id to send the changes to.

Returns:

  • The message as a dict.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.send_style**(self, style_items, channel_id, recipients)

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.

Returns:

  • The message as a dict.

Raises:

  • (this function does not raise any notable errors)

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.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.

Signature:

  • **Moobius.send_join_channel**(self, channel_id)

Parameters:

  • __channel_id:__ The channel_id.

Returns:

  • The message sent.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.send_leave_channel**(self, channel_id)

Parameters:

  • __channel_id:__ The channel_id.

Returns:

  • The message sent.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.send_button_click**(self, button_id, bottom_button_id, button_args, channel_id)

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.

Returns:

  • The message sent as a dict.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.send_menu_item_click**(self, menu_item_id, bottom_button_id, button_args, the_message, channel_id)

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.

Returns:

  • The message sent as a dict.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.listen_loop**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • The Never.

Raises:

  • (this function does not raise any notable errors)

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).

Signature:

  • **Moobius.handle_received_payload**(self, payload)

Parameters:

  • __payload:__ Payload string.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

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().

Signature:

  • **Moobius.on_action**(self, action_data)

Parameters:

  • __action_data:__ Action data (as a dict) from a user.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.on_update**(self, update)

Parameters:

  • __update:__ N Update object from the socket.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_start#

Called when the service is initialized.

Signature:

  • **Moobius.on_start**(self)

Parameters:

  • __(this class constructor accepts no arguments):__

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.on_channel_init**(self, channel_id)

Parameters:

  • __channel_id:__ Channel ID.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_spell#

Called when a “spell” from the wand is received, which can be any object but is often a string..

Signature:

  • **Moobius.on_spell**(self, obj)

Parameters:

  • __obj:__ The wand sent this process.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_message_up#

Example MessageBody object: >>> moobius.MessageBody(subtype=”text”, channel_id=<channel id>, content=MessageContent(…), timestamp=1707254706635, >>> recipients=[<user id 1>, <user id 2>], sender=<user id>, message_id=<message-id>, >>> context={‘group_id’: <group-id>, ‘channel_type’: ‘ccs’}).

Signature:

  • **Moobius.on_message_up**(self, message)

Parameters:

  • __message:__ A message from a user.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_copy_client#

Example Copy object: >>> moobius.Copy(request_id=<id>, origin_type=message_down, status=True, context={‘message’: ‘Message received’}).

Signature:

  • **Moobius.on_copy_client**(self, copy)

Parameters:

  • __copy:__ A “Copy” request from the user.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_refresh#

Signature:

  • **Moobius.on_refresh**(self, action)

Parameters:

  • __action:__ A “Copy” request from the user.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.on_join**(self, action)

Parameters:

  • __action:__ Channel and member id.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_leave#

Called when the user leaves a channel.. Commonly used to update everyone’s character list.

Signature:

  • **Moobius.on_leave**(self, action)

Parameters:

  • __action:__ Channel and member id.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_button_click#

Handles a button click from a user.. Example ButtonClick object: >>> moobius.ButtonClick(button_id=”the_big_red_button”, channel_id=<channel id>, sender=<user id>, components=[], context={}).

Signature:

  • **Moobius.on_button_click**(self, action)

Parameters:

  • __action:__ User’s ButtonClick.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_menu_item_click#

Handles a context menu right click from a user.. Example MenuItemClick object: >>> MenuItemClick(item_id=1, message_id=<id>, message_subtypes=text, message_content={‘text’: ‘Click on this message.’}, channel_id=<channel_id>, context={}, recipients=[]).

Signature:

  • **Moobius.on_menu_item_click**(self, action)

Parameters:

  • __action:__ User’s MenuItemClick.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_unknown_payload#

A catch-all for handling unknown payloads..

Signature:

  • **Moobius.on_unknown_payload**(self, payload_data)

Parameters:

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

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_message_down#

Callback when the user recieves a message.. Use for user mode.

Signature:

  • **Moobius.on_message_down**(self, message)

Parameters:

  • __message:__ Service’s MessageBody.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_update_characters#

Callback when the user recieves the character list.. One of the multiple update callbacks. Use for user mode.

Signature:

  • **Moobius.on_update_characters**(self, update)

Parameters:

  • __update:__ Service’s Update.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_update_channel_info#

Callback when the user recieves the channel info.. One of the multiple update callbacks. Use for user mode.

Signature:

  • **Moobius.on_update_channel_info**(self, update)

Parameters:

  • __update:__ Service’s Update.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_update_canvas#

Callback when the user recieves the canvas content.. One of the multiple update callbacks. Use for user mode.

Signature:

  • **Moobius.on_update_canvas**(self, update)

Parameters:

  • __update:__ Service’s Update.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_update_buttons#

Callback when the user recieves the buttons.. One of the multiple update callbacks. Use for user mode.

Signature:

  • **Moobius.on_update_buttons**(self, update)

Parameters:

  • __update:__ Service’s Update.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

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.

Signature:

  • **Moobius.on_update_style**(self, update)

Parameters:

  • __update:__ Service’s Update.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Moobius.on_update_menu#

Callback when the user recieves the context menu info.. One of the multiple update callbacks. Use for user mode.

Signature:

  • **Moobius.on_update_menu**(self, update)

Parameters:

  • __update:__ Service’s Update.

Returns:

  • None.

Raises:

  • (this function does not raise any notable errors)

Class attributes#

Internals#