Public Member Functions | |
| None | __init__ (self, str command_marker="/", RateLimits rate_limits=DISABLE_RATE_LIMITS, bool debug=False) |
| None | run (self, str username, str location, bool create_help_command=False) |
| Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]] | command (self, str name, str description="", list[CommandParameter] parameters=[], list[str] aliases=[], bool hidden=False) |
| bool | create_room (self, str room_name, RoomType room_type=RoomType.PUBLIC, RoomLayoutType room_layout=RoomLayoutType.VERTICAL, int|None room_password=None) |
| None | disconnect (self) |
| Room|None | get_room_by_id (self, int id) |
| User|None | get_user_by_id (self, str id) |
| str | get_user_message (self, User user) |
| bool | join_room (self, Room|int room, int|None access_code=None, bool do_api_check=True) |
| None | leave_room (self) |
| Binding | on_connect (self, Binding binding) |
| Binding | on_inactivity_disconnect (self, Binding binding) |
| Binding | on_room_creation (self, Binding binding) |
| Binding | on_room_join (self, Binding binding) |
| Binding | on_room_leave (self, Binding binding) |
| Binding | on_user_message (self, Binding binding) |
| Binding | on_user_join (self, Binding binding) |
| Binding | on_user_leave (self, Binding binding) |
| Binding | on_user_vote (self, Binding binding) |
| bool | send_message (self, str message) |
| None | toggle_vote (self, User user) |
Public Attributes | |
| sio = AsyncClient(engineio_logger = debug, logger = debug) | |
| rate_limits = rate_limits | |
| command_marker = command_marker | |
| user = User.from_raw_json(data) | |
Static Public Attributes | |
| Room | current_room = None |
| dict | commands = {} |
| list | rooms = [] |
| dict | user_database = {} |
| dict | user_messages = {} |
| Binding | on_connect_binding = None |
| Binding | on_inactivity_disconnect_binding = None |
| Binding | on_room_creation_binding = None |
| Binding | on_room_join_binding = None |
| Binding | on_room_leave_binding = None |
| Binding | on_user_message_binding = None |
| Binding | on_user_join_binding = None |
| Binding | on_user_leave_binding = None |
| Binding | on_user_vote_binding = None |
Protected Member Functions | |
| None | _run (self, str username, str location) |
| None | _chat_update (self, dict data) |
| None | _error (self, dict data) |
| None | _join_lobby (self, str username, str location) |
| None | _lobby_update (self, list[dict] rooms_data) |
| None | _signin_status (self, dict data) |
| None | _room_join (self, dict data) |
| None | _room_update (self, dict data) |
| None | _user_join (self, dict data) |
| None | _user_leave (self, str data) |
| None | _update_votes (self, dict data) |
Protected Attributes | |
| _signin_status | |
| _lobby_update | |
| _chat_update | |
| _room_join | |
| _room_update | |
| _user_join | |
| _user_leave | |
| _update_votes | |
| _error | |
Static Protected Attributes | |
| bool | _fully_started = False |
| float | _time_since_last_message = 0 |
| float | _time_since_last_room_join = 0 |
| float | _time_since_last_room_creation = 0 |
A wrapper class around the socket.io Talkomatic API. This bot uses
an asynchronous socket.io client to optimize for concurrency,
while abstracting error handling, disconnecting, and other low-level
details, to make writing bots easier.
Args:
username (str): The username of the bot.
location (str): The location of the bot.
The bot's name will show up as "username / location".
Optional:
rate_limits (RateLimits): The rate limits of the bot. (disabled by default to make
development easier, consider putting rate limits in to prevent getting blocked by the API)
debug (bool): Whether to enable debug mode for the internal socket.io
client. Defaults to False.
| None talkomatic.bot.Bot.__init__ | ( | self, | |
| str | command_marker = "/", | ||
| RateLimits | rate_limits = DISABLE_RATE_LIMITS, | ||
| bool | debug = False ) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]] talkomatic.bot.Bot.command | ( | self, | |
| str | name, | ||
| str | description = "", | ||
| list[CommandParameter] | parameters = [], | ||
| list[str] | aliases = [], | ||
| bool | hidden = False ) |
Decorator for registering commands.
Args:
name (str): The name of the command.
description (str): The description of the command.
parameters (list[CommandParameter]): The parameters of the command.
aliases (list[str]): The aliases of the command.
hidden (bool): Whether the command will show up in the built-in /help command.
| bool talkomatic.bot.Bot.create_room | ( | self, | |
| str | room_name, | ||
| RoomType | room_type = RoomType.PUBLIC, | ||
| RoomLayoutType | room_layout = RoomLayoutType.VERTICAL, | ||
| int | None | room_password = None ) |
Creates a room with the given name, type, layout, and password.
Args:
room_name (str): The name of the room.
room_type (RoomType): The type of the room.
room_layout (RoomLayoutType): The layout of the room.
room_password (int, **must be 6 digits**): The password of the room (if the room is not public).
Returns:
bool: Whether the room was created successfully (returns False if the room was
not created due to rate limits).
| None talkomatic.bot.Bot.disconnect | ( | self | ) |
| Room | None talkomatic.bot.Bot.get_room_by_id | ( | self, | |
| int | id ) |
| User | None talkomatic.bot.Bot.get_user_by_id | ( | self, | |
| str | id ) |
Allows you to get a user from the user database by their ID.
Useful for getting a user from a "id-only" user, but is not
guaranteed to work if the user is not in a room anymore.
Args:
id (str): The ID of the user to get.
Returns:
User: The full user object. (None if the user is not in the database)
| str talkomatic.bot.Bot.get_user_message | ( | self, | |
| User | user ) |
| bool talkomatic.bot.Bot.join_room | ( | self, | |
| Room | int | room, | ||
| int | None | access_code = None, | ||
| bool | do_api_check = True ) |
Joins a room with the given room/room ID and access code.
**Reminder: your bot can only be in 1 room at a time!**
Args:
room (Room | int): The room (or ID of the room) to join.
access_code (int | None): The 6 digit access code of the room to join (if the room is not public).
do_api_check (bool): Whether to check if the room can be joined using the Talkomatic API.
Returns:
bool: Whether the room was joined successfully (returns False if the room was
not joined due to rate limits).
| None talkomatic.bot.Bot.leave_room | ( | self | ) |
| None talkomatic.bot.Bot.run | ( | self, | |
| str | username, | ||
| str | location, | ||
| bool | create_help_command = False ) |
| bool talkomatic.bot.Bot.send_message | ( | self, | |
| str | message ) |
| None talkomatic.bot.Bot.toggle_vote | ( | self, | |
| User | user ) |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
static |
|
static |
|
static |
|
static |
| talkomatic.bot.Bot.sio = AsyncClient(engineio_logger = debug, logger = debug) |
| talkomatic.bot.Bot.user = User.from_raw_json(data) |