Mumpy Object¶
-
class
mumpy.mumpy.
Mumpy
(username='mumble-bot', password='')¶ -
add_event_handler
(event_type, function_handle)¶ Adds the function as a handler for the specified event type. When an event is fired, any functions added as handlers for that event type will be run with two arguments, the Mumpy instance that the event originated from (in case you have multiple instances running), as well as the protobuf message that caused the event to be fired.
Example:
def kick_handler_function(mumpy_instance, raw_message): kicked_user = mumpy_instance.get_user_by_id(raw_message.session) kicker_session_id = raw_message.actor reason = raw_message.reason bot.add_event_handler(MumpyEvent.USER_KICKED, kick_handler_function)
Parameters: - event_type (str) – an event from the
MumpyEvent
enum - function_handle (function) – the function to run when the specified event is fired
Returns: None
- event_type (str) – an event from the
-
channel_id
¶ the ID of the channel the bot is currently in
Type: Returns Type: int
-
clear_all_audio_logs
()¶ Clears every user’s audio log, removing all received audio transmissions from memory.
-
connect
(address, port=64738, certfile=None, keyfile=None, keypassword=None)¶ Starts the connection thread that connects to address:port. Optionally uses an SSL certificate in PEM format to identify the client.
Parameters: - address (str) – string containing either an IP address, FQDN, hostname, etc.
- port (int) – the TCP port that the server is running on (Default value = 64738)
- certfile (str, optional) – the path to the SSL certificate file in PEM format (Default value = None)
- keyfile (str, optional) – the path to the certificate’s key file (Default value = None)
- keypassword (str, optional) – the secret key used to unlock the key file (Default value = None)
Returns: None
-
deafen_self
()¶ Deafens the Mumpy instance on the server.
Returns: None
-
deafen_user
(user)¶ Deafens a user on the server.
Parameters: user (User) – the user to deafen Returns: None
-
disconnect
()¶ Closes the connection to the server.
Returns: None
-
export_audio_logs_to_wav
(folder='./')¶ Converts all audio logs from all users to WAV and saves them to separate files. Clears all audio logs once the audio has been saved.
Parameters: folder (str) – the output directory (Default value = ‘./’) Returns: None
-
get_channel_by_id
(channel_id)¶ Parameters: channel_id (int) – the ID of the channel Returns: the Channel identified by channel_id Return type: Channel
-
get_channel_by_name
(name)¶ Parameters: name (str) – the name of the channel Returns: the Channel identified by name Return type: Channel
-
get_channel_permissions
(channel)¶ Retrieves the Mumpy instance’s permissions in the specified Channel. This function does not return anything. The server’s response may fire the following events: - CHANNEL_PERMISSIONS_UPDATED
Parameters: channel (Channel) – the Channel to retrieve permissions for Returns: None
-
get_channels
()¶ Returns: a dictionary of Channel
objects and IDs in the form<Mumpy>.get_channels()[id] = Channel()
Return type: dict
-
get_registered_users
()¶ Retrieves the list of registered users from the server. This function does not return anything. The server’s response may fire the following events: - REGISTERED_USER_LIST_RECEIVED
Returns: None
-
get_user_by_id
(session_id)¶ Parameters: session_id (int) – the session ID of the user Returns: the User identified by session_id Return type: User
-
get_user_by_name
(name)¶ Parameters: name (str) – the name of the user Returns: the User identified by name Return type: User
-
get_users
()¶ Returns: a dictionary of get_users()[id] = User()`
Return type: dict
-
is_alive
()¶ Returns: True if bot is connected to the server Return type: bool
-
is_udp_alive
()¶ Returns: True if the bot has an active UDP connection to the server Return type: bool
-
join_channel
(channel)¶ Moves the Mumpy instance to the specified Channel.
Parameters: channel (Channel) – the channel to move to Returns: None
-
kick_user
(user, reason='', ban=False)¶ Kicks a User. Bans the User if ban is True.
Parameters: - user (User) – the target User
- reason (str) – the reason for this action (Default value = “”)
- ban (bool) – whether or not the user should be banned as well (Default value = False)
Returns: None
-
kick_user_by_name
(name, reason='', ban=False)¶ Kicks a user identified by name. Bans the user if ban is True.
Parameters: - name (str) – the target User’s name
- reason (str) – the reason for this action (Default value = “”)
- ban (bool) – whether or not the user should be banned as well (Default value = False)
Returns: None
-
move_user_to_channel
(user, channel)¶ Moves the User to the specified Channel.
Parameters: Returns: None
-
mute_self
()¶ Mutes the Mumpy instance on the server.
Returns: None
-
ping
(udp=False)¶ Sends a Ping packet to the server, as specified by the Mumble protocol.
Parameters: udp (boolean) – if True, sends a UDP ping. Otherwise, sends a TCP ping. (Default value = False) Returns: None
-
play_wav
(filename)¶ Reads a WAV file and then sends it as an audio transmission.
Parameters: filename (str) – the path to the WAV file Returns: None
-
register_self
()¶ Registers the Mumpy instance on the server.
Returns: None
-
register_user
(user)¶ Registers a User on the server.
Parameters: user (User) – the User to register Returns: None
-
remove_channel
(channel)¶ Removes a channel.
Parameters: channel (Channel) – the channel to remove Returns: None
-
rename_channel
(channel, new_name)¶ Changes a channel’s name to new_name.
Parameters: - channel (Channel) – the channel to rename
- new_name (str) – the new name
Returns: None
-
request_blob
(user_textures=(), user_comments=(), channel_descriptions=())¶ Queries the server for the full contents of a User’s texture or comment, or a Channel’s description.
Parameters: - user_textures (iterable) – a list of Users to retrieve textures for (Default value = ())
- user_comments (iterable) – a list of Users to retrieve comments for (Default value = ())
- channel_descriptions (iterable) – a list of Channels to retrieve descriptions for (Default value = ())
Events
- USER_COMMENT_UPDATED
- USER_TEXTURE_UPDATED
- CHANNEL_UPDATED
-
send_audio
(pcm, sample_rate=48000, sample_width=2)¶ Encodes raw PCM data using the preferred audio codec and transmits it to the server.
Parameters: - pcm (bytes) – the raw PCM data
- sample_rate (int) – the sample rate of the PCM data (Default value = 48000)
- sample_width (int) – the sample width of the PCM data (AKA the bit depth, but in bytes) (Default value = 2)
Returns: None
-
text_message
(message, channels=(), users=())¶ Sends a text message to each Channel in the list channels, and to each User in the list users. If no channels or users are specified, sends the message to the bot’s current channel.
Parameters: - message (str) – the text message
- channels (iterable) – a list of channels to send the message to (Default value = ())
- users (iterable) – a list of users to send the message to (Default value = ())
Returns: None
-
undeafen_self
()¶ Undeafens the Mumpy instance on the server.
Returns: None
-
undeafen_user
(user)¶ Undeafens a user on the server.
Parameters: user (User) – the user to undeafen Returns: None
-
unmute_self
()¶ Unmutes the Mumpy instance on the server.
Returns: None
-
unmute_user
(user)¶ Unmutes a user on the server.
Parameters: user (User) – the user to unmute Returns: None
-
unregister_self
()¶ Unregisters the Mumpy instance on the server.
Returns: None
-