telegram.Chat¶
-
class
telegram.
Chat
(id: int, type: str, title: str = None, username: str = None, first_name: str = None, last_name: str = None, bot: Bot = None, photo: telegram.files.chatphoto.ChatPhoto = None, description: str = None, invite_link: str = None, pinned_message: Message = None, permissions: telegram.chatpermissions.ChatPermissions = None, sticker_set_name: str = None, can_set_sticker_set: bool = None, slow_mode_delay: int = None, **kwargs)¶ Bases:
telegram.base.TelegramObject
This object represents a chat.
Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their
id
is equal.-
id
¶ Unique identifier for this chat.
Type: int
-
type
¶ Type of chat.
Type: str
-
title
¶ Optional. Title, for supergroups, channels and group chats.
Type: str
-
username
¶ Optional. Username.
Type: str
-
first_name
¶ Optional. First name of the other party in a private chat.
Type: str
-
last_name
¶ Optional. Last name of the other party in a private chat.
Type: str
-
photo
¶ Optional. Chat photo.
Type: telegram.ChatPhoto
-
description
¶ Optional. Description, for groups, supergroups and channel chats.
Type: str
-
invite_link
¶ Optional. Chat invite link, for supergroups and channel chats.
Type: str
-
pinned_message
¶ Optional. Pinned message, for supergroups. Returned only in
telegram.Bot.get_chat()
.Type: telegram.Message
-
permissions
¶ Optional. Default chat member permissions, for groups and supergroups. Returned only in
telegram.Bot.get_chat()
.Type: telegram.ChatPermissions
-
slow_mode_delay
¶ Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user. Returned only in
telegram.Bot.get_chat()
.Type: int
-
sticker_set_name
¶ Optional. For supergroups, name of Group sticker set.
Type: str
-
can_set_sticker_set
¶ Optional.
True
, if the bot can change group the sticker set.Type: bool
Parameters: - id (
int
) – Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. - type (
str
) – Type of chat, can be either ‘private’, ‘group’, ‘supergroup’ or ‘channel’. - title (
str
, optional) – Title, for supergroups, channels and group chats. - username (
str
, optional) – Username, for private chats, supergroups and channels if available. - first_name (
str
, optional) – First name of the other party in a private chat. - last_name (
str
, optional) – Last name of the other party in a private chat. - photo (
telegram.ChatPhoto
, optional) – Chat photo. Returned only intelegram.Bot.get_chat()
. - description (
str
, optional) – Description, for groups, supergroups and channel chats. Returned only intelegram.Bot.get_chat()
. - invite_link (
str
, optional) – Chat invite link, for groups, supergroups and channel chats. Each administrator in a chat generates their own invite links, so the bot must first generate the link usingexport_chat_invite_link()
. Returned only intelegram.Bot.get_chat()
. - pinned_message (
telegram.Message
, optional) – Pinned message, for groups, supergroups and channels. Returned only intelegram.Bot.get_chat()
. - permissions (
telegram.ChatPermissions
) – Optional. Default chat member permissions, for groups and supergroups. Returned only intelegram.Bot.get_chat()
. - slow_mode_delay (
int
, optional) – For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user. Returned only intelegram.Bot.get_chat()
. - bot (
telegram.Bot
, optional) – The Bot to use for instance methods. - sticker_set_name (
str
, optional) – For supergroups, name of group sticker set. Returned only intelegram.Bot.get_chat()
. - can_set_sticker_set (
bool
, optional) –True
, if the bot can change group the sticker set. Returned only intelegram.Bot.get_chat()
. - **kwargs (
dict
) – Arbitrary keyword arguments.
-
CHANNEL
= 'channel'¶ ‘channel’
Type: str
-
GROUP
= 'group'¶ ‘group’
Type: str
-
PRIVATE
= 'private'¶ ‘private’
Type: str
-
SUPERGROUP
= 'supergroup'¶ ‘supergroup’
Type: str
-
get_administrators
(*args, **kwargs) → List[ChatMember]¶ Shortcut for:
bot.get_chat_administrators(update.effective_chat.id, *args, **kwargs)
Returns: A list of administrators in a chat. An Array of telegram.ChatMember
objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.Return type: List[ telegram.ChatMember
]
-
get_member
(*args, **kwargs) → ChatMember¶ Shortcut for:
bot.get_chat_member(update.effective_chat.id, *args, **kwargs)
Returns: telegram.ChatMember
-
get_members_count
(*args, **kwargs) → int¶ Shortcut for:
bot.get_chat_members_count(update.effective_chat.id, *args, **kwargs)
Returns: int
-
kick_member
(*args, **kwargs) → bool¶ Shortcut for:
bot.kick_chat_member(update.effective_chat.id, *args, **kwargs)
Returns: If the action was sent successfully. Return type: bool
Note
This method will only work if the All Members Are Admins setting is off in the target group. Otherwise members may only be removed by the group’s creator or by the member that added them.
-
leave
(*args, **kwargs) → bool¶ Shortcut for:
bot.leave_chat(update.effective_chat.id, *args, **kwargs)
Returns: bool
If the action was sent successfully.
-
send_action
(*args, **kwargs) → bool¶ Alias for
send_chat_action
-
send_animation
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_animation(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_audio
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_audio(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_chat_action
(*args, **kwargs) → bool¶ Shortcut for:
bot.send_chat_action(update.effective_chat.id, *args, **kwargs)
Returns: On success. Return type: True
-
send_contact
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_contact(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_dice
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_dice(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_document
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_document(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_game
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_game(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_invoice
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_invoice(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_location
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_location(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_media_group
(*args, **kwargs) → List[Message]¶ Shortcut for:
bot.send_media_group(update.effective_chat.id, *args, **kwargs)
Returns: ] On success, instance representing the message posted. Return type: List[ telegram.Message
-
send_message
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_message(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_photo
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_photo(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_poll
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_poll(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_sticker
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_sticker(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_venue
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_venue(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_video
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_video(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_video_note
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_video_note(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
send_voice
(*args, **kwargs) → Message¶ Shortcut for:
bot.send_voice(update.effective_chat.id, *args, **kwargs)
Returns: On success, instance representing the message posted. Return type: telegram.Message
-
set_administrator_custom_title
(*args, **kwargs) → bool¶ Shortcut for:
bot.set_chat_administrator_custom_title(update.effective_chat.id, *args, **kwargs)
Returns:
bool
: If the action was sent successfully.
-
set_permissions
(*args, **kwargs) → bool¶ Shortcut for:
bot.set_chat_permissions(update.effective_chat.id, *args, **kwargs)
Returns: If the action was sent successfully. Return type: bool
-
unban_member
(*args, **kwargs) → bool¶ Shortcut for:
bot.unban_chat_member(update.effective_chat.id, *args, **kwargs)
Returns: If the action was sent successfully. Return type: bool
-