Bot commands framework API
- class Antiland.ext.commands.Bot(prefix, dialogue, session_token=None)[source]
The Bot class represents a bot on the Antiland platform, providing a variety of features and methods for interacting with the platform.
- Parameters:
prefix (str) – The command prefix to trigger bot commands.
dialogue (str) – The ID of the dialogue associated with the bot.
session_token (str, optional) – The session token for authentication. Defaults to None.
- prefix
The command prefix to trigger bot commands.
- Type:
str
- running
A flag to indicate if the bot is currently running.
- Type:
bool
- token
The authentication token.
- Type:
str
- session_token
The session token for authentication.
- Type:
str
- message_updater
An instance of the MessageUpdater class for managing incoming messages.
- Type:
MessageUpdater
- commands
A dictionary to store user-defined bot commands.
- Type:
dict
- events
A dictionary to store user-defined event handlers.
- Type:
dict
- dialogue
The ID of the dialogue associated with the bot.
- Type:
str
- chats
A dictionary to store chat-related data.
- Type:
dict
- url
The URL for subscribing to chat updates.
- Type:
str
- process_message(message, token)
Process incoming messages and execute commands.
- login(token)
Log in to the Antiland platform and retrieve user information.
- update_profile(session_token, **kwargs)[source]
Update the bot’s profile with specified attributes.
Examples
bot = Bot(prefix=’!’, dialogue=’4fkzGJsDs2’, session_token=’r:68ff2243463ee75afb4218f0a584b543’) bot.start(‘your_auth_token’) # Start the bot with your authentication token.
- Usage:
Create a Bot instance by providing a command prefix, optional dialogue ID,session token.
Define bot commands using the @bot.command decorator and event handlers using the @bot.event decorator.
Start the bot with your authentication token using the start method.
The bot processes incoming messages, executes commands, and triggers event handlers based on message content.
Use various methods to interact with the Antiland platform, manage contacts, and perform actions within chat dialogues.
Note
This class provides a framework for building and running an Antiland bot. You can extend its functionality by defining custom commands and event handlers.
- async add_contact(uuid, token)[source]
Add a contact to the bot’s contact list.
- Parameters:
uuid (str) – The UUID of the contact to be added.
token (str) – The authentication token for the bot.
- Returns:
A User instance representing the specified user.
- Return type:
- async block_user(uuid, token)[source]
Block a user.
- Parameters:
uuid (str) – The UUID of the user to be blocked.
token (str) – The authentication token for the bot.
- async delete_contact(uuid, token)[source]
Delete a contact from the bot’s contact list.
- Parameters:
uuid (str) – The UUID of the contact to be deleted.
token (str) – The authentication token for the bot.
- async exit_chat(token, dialogue)[source]
Exit a chat dialogue.
- Parameters:
token (str) – The authentication token for the bot.
dialogue (str) – The ID of the chat dialogue to exit.
- async get_contacts(token)[source]
Get the bot’s contacts.
- Parameters:
token (str) – The authentication token for the bot.
- Returns:
A list of User instances representing bot contacts.
- Return type:
list
- async get_dialogue(dialogue, token)[source]
Get information about a specific dialogue.
- Parameters:
dialogue (str) – The ID of the dialogue to retrieve information for.
token (str) – The authentication token for the bot.
- Returns:
A Dialogue instance representing the specified dialogue.
- Return type:
- async get_stats(session_token)[source]
Get account statistics.
- Parameters:
session_token (str) – The session token for authentication.
- Returns:
An Account instance containing account statistics.
- Return type:
- async get_topchats(token)[source]
Get the top chat dialogues.
- Parameters:
token (str) – The authentication token for the bot.
- Returns:
A list of Dialogue instances representing the top chat dialogues.
- Return type:
list
- async join_chat(token, dialogue)[source]
Join a chat dialogue.
- Parameters:
token (str) – The authentication token for the bot.
dialogue (str) – The ID of the chat dialogue to join.
- async send_gift(gift_type, reciever, dialogue, session_token)[source]
Send a gift
Parameters: gift_type (str): The type of gift to send e.g. rose. reciever (str): The recipient’s ID or username. dialogue (str): The ID of the dialogue or conversation related to the gift. session_token (str): A session token for authentication and authorization.
Example: result = await bot.send_gift(“rose”, “user123”, “dialogue456”, “your_session_token_here”) print(result)
- async translate(token, message, message_id)[source]
Translate a message.
- Parameters:
token (str) – The authentication token for the bot.
message (str) – The message to be translated.
message_id (str) – The message ID.
- Returns:
The translated message.
- Return type:
str