pyrobale.objects.chat¶
Classes¶
Represents a chat in the Bale messenger. |
Module Contents¶
- class pyrobale.objects.chat.Chat(id=None, type=None, title=None, username=None, first_name=None, last_name=None, photo=None, client=None, **kwargs)[source]¶
Represents a chat in the Bale messenger.
- Parameters:
id (Optional[int]) – Unique identifier for this chat
type (Optional[str]) – Type of chat, can be either “private”, “group”, or “channel”
title (Optional[str]) – Title, for groups and channels
username (Optional[str]) – Username, for private chats and channels if available
first_name (Optional[str]) – First name of the other party in a private chat
last_name (Optional[str]) – Last name of the other party in a private chat
photo (Optional[ChatPhoto]) – Chat photo object
**kwargs – Additional keyword arguments
client (Optional[pyrobale.client.Client])
- photo: pyrobale.objects.chatphoto.ChatPhoto = None[source]¶
- client: pyrobale.client.Client = None[source]¶
- async send_message(text, reply_to_message_id=None, reply_markup=None)[source]¶
Send a message to the chat.
- Parameters:
text (str) – Text of the message to be sent
reply_to_message_id (int, optional) – If the message is a reply, ID of the original message
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional) – Additional interface options
- Returns:
The sent message object
- Return type:
- async get_chat_member(user_id)[source]¶
Get information about a member of a chat.
- Parameters:
user_id (int) – Unique identifier of the target user
- Returns:
Information about the chat member
- Return type:
- async get_chat_members_count()[source]¶
Get the number of members in the chat.
- Returns:
Number of members in the chat
- Return type:
int
- async send_photo(photo, caption=None, reply_to_message_id=None, reply_markup=None)[source]¶
Send a photo to the chat.
- Parameters:
photo (str) – Photo to send (file_id or URL)
caption (Optional[str]) – Photo caption
reply_to_message_id (int, optional) – If the message is a reply, ID of the original message
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional) – Additional interface options
- Returns:
The sent message object
- Return type:
- async send_video(video, caption=None, reply_to_message_id=None, reply_markup=None)[source]¶
Send a video to the chat.
- Parameters:
video (str) – Video to send (file_id or URL)
caption (Optional[str]) – Video caption
reply_to_message_id (int, optional) – If the message is a reply, ID of the original message
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional) – Additional interface options
- Returns:
The sent message object
- Return type:
- async send_audio(audio, caption=None, reply_to_message_id=None, reply_markup=None)[source]¶
Send an audio file to the chat.
- Parameters:
audio (str) – Audio file to send (file_id or URL)
caption (Optional[str]) – Audio caption
reply_to_message_id (int, optional) – If the message is a reply, ID of the original message
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional) – Additional interface options
- Returns:
The sent message object
- Return type:
- async send_document(document, caption=None, reply_to_message_id=None, reply_markup=None)[source]¶
Send a document to the chat.
- Parameters:
document (str) – Document to send (file_id or URL)
caption (Optional[str]) – Document caption
reply_to_message_id (int, optional) – If the message is a reply, ID of the original message
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional) – Additional interface options
- Returns:
The sent message object
- Return type:
- async send_sticker(sticker, reply_to_message_id=None, reply_markup=None)[source]¶
Send a sticker to the chat.
- Parameters:
sticker (str) – Sticker to send (file_id or URL)
reply_to_message_id (int, optional) – If the message is a reply, ID of the original message
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional) – Additional interface options
- Returns:
The sent message object
- Return type:
- async send_voice(voice, caption=None, reply_to_message_id=None, reply_markup=None)[source]¶
Send a voice message to the chat.
- Parameters:
voice (str) – Voice message to send (file_id or URL)
caption (Optional[str]) – Voice message caption
reply_to_message_id (int, optional) – If the message is a reply, ID of the original message
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional) – Additional interface options
- Returns:
The sent message object
- Return type:
- async send_location(latitude, longitude, reply_to_message_id=None, reply_markup=None)[source]¶
Send a location to the chat.
- Parameters:
latitude (float) – Latitude of the location
longitude (float) – Longitude of the location
reply_to_message_id (int, optional) – If the message is a reply, ID of the original message
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional) – Additional interface options
- Returns:
The sent message object
- Return type:
- async send_contact(phone_number, first_name, last_name=None, reply_to_message_id=None, reply_markup=None)[source]¶
Send a contact to the chat.
- Parameters:
phone_number (str) – Contact’s phone number
first_name (str) – Contact’s first name
last_name (Optional[str]) – Contact’s last name
reply_to_message_id (int, optional) – If the message is a reply, ID of the original message
reply_markup (Union[ReplyKeyboardMarkup, InlineKeyboardMarkup], optional) – Additional interface options
- Returns:
The sent message object
- Return type:
- async ban(user_id)[source]¶
Bans a user from the chat.
- Parameters:
user_id (int) – Unique identifier of the target user
until_date (Optional[int]) – Date when the user will be unbanned (Unix time)
- Returns:
True on success
- Return type:
bool
- async kick(user_id)[source]¶
Kicks a user from the chat.
- Parameters:
user_id (int) – Unique identifier of the target user
- Returns:
True on success
- Return type:
bool
- async unban(user_id)[source]¶
Unban a previously banned user in the chat.
- Parameters:
user_id (int) – Unique identifier of the target user
- Returns:
True on success
- Return type:
bool
- async promote(user_id, can_change_info=None, can_post_messages=None, can_edit_messages=None, can_delete_messages=None, can_invite_users=None, can_restrict_members=None, can_pin_messages=None, can_promote_members=None)[source]¶
Promote or demote a user in a chat.
- Parameters:
user_id (int) – Unique identifier of the target user
can_change_info (Optional[bool]) – Pass True if the user can change chat title, photo and other settings
can_post_messages (Optional[bool]) – Pass True if the user can post messages in channels
can_edit_messages (Optional[bool]) – Pass True if the user can edit messages in channels
can_delete_messages (Optional[bool]) – Pass True if the user can delete messages
can_invite_users (Optional[bool]) – Pass True if the user can invite new users
can_restrict_members (Optional[bool]) – Pass True if the user can restrict, ban or unban chat members
can_pin_messages (Optional[bool]) – Pass True if the user can pin messages
can_promote_members (Optional[bool]) – Pass True if the user can add new administrators
- Returns:
True on success
- Return type:
bool
- async is_joined(user_id)[source]¶
Check if a user is joined to the chat.
- Parameters:
user_id (int) – Unique identifier of the target user
- Returns:
True if the user is joined to the chat, False otherwise
- Return type:
bool
- async pin(message_id)[source]¶
Pin a message in the chat.
- Parameters:
message_id (int) – Identifier of a message to pin
- Returns:
True on success
- Return type:
bool
- async unpin(message_id)[source]¶
Unpin a message in the chat.
- Returns:
True on success
- Return type:
bool
- Parameters:
message_id (int)
- async unpin_all()[source]¶
Unpin all messages in the chat.
- Returns:
True on success
- Return type:
bool
- async set_title(title)[source]¶
Change the title of a chat.
- Parameters:
title (str) – New chat title, 1-255 characters
- Returns:
True on success
- Return type:
bool
- async set_description(description)[source]¶
Change the description of a chat.
- Parameters:
description (str) – New chat description, 0-255 characters
- Returns:
True on success
- Return type:
bool
- async set_photo(photo)[source]¶
Set the photo of the chat.
- Parameters:
photo (str) – Photo to set. Pass a file_id as string to send a photo that exists on the Telegram servers, pass an HTTP URL as a string for Telegram to get a photo from the Internet, or pass “attach://<file_attach_name>” to upload a new photo that exists on the local server.
- Returns:
True on success
- Return type:
bool
- async send_action(action)[source]¶
Send an action to the chat.
- Parameters:
action (objects.enums.ChatAction) – Action to send to the chat
- Returns:
True on success
- Return type:
bool