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, bio: str = None, linked_chat_id: int = None, location: telegram.chatlocation.ChatLocation = 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
bio

Optional. Bio of the other party in a private chat. Returned only in telegram.Bot.get_chat().

Type:str
description

Optional. Description, for groups, supergroups and channel chats.

Type:str

Optional. Chat invite link, for supergroups and channel chats.

Type:str
pinned_message

Optional. The most recent pinned message (by sending date). 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
linked_chat_id

Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. Returned only in telegram.Bot.get_chat().

Type:int
location

Optional. For supergroups, the location to which the supergroup is connected. Returned only in telegram.Bot.get_chat().

Type:telegram.ChatLocation
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 in telegram.Bot.get_chat().
  • bio (str, optional) – Bio of the other party in a private chat. Returned only in telegram.Bot.get_chat().
  • description (str, optional) – Description, for groups, supergroups and channel chats. Returned only in telegram.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 using export_chat_invite_link(). Returned only in telegram.Bot.get_chat().
  • pinned_message (telegram.Message, optional) – The most recent pinned message (by sending date). Returned only in telegram.Bot.get_chat().
  • permissions (telegram.ChatPermissions) – Optional. Default chat member permissions, for groups and supergroups. Returned only in telegram.Bot.get_chat().
  • slow_mode_delay (int, optional) – For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user. Returned only in telegram.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 in telegram.Bot.get_chat().
  • can_set_sticker_set (bool, optional) – True, if the bot can change group the sticker set. Returned only in telegram.Bot.get_chat().
  • linked_chat_id (int, optional) – Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. Returned only in telegram.Bot.get_chat().
  • location (telegram.ChatLocation, optional) – For supergroups, the location to which the supergroup is connected. Returned only in telegram.Bot.get_chat().
  • **kwargs (dict) – Arbitrary keyword arguments.
CHANNEL = 'channel'

telegram.constants.CHAT_CHANNEL

GROUP = 'group'

telegram.constants.CHAT_GROUP

PRIVATE = 'private'

telegram.constants.CHAT_PRIVATE

SUPERGROUP = 'supergroup'

telegram.constants.CHAT_SUPERGROUP

copy_message(*args, **kwargs) → MessageId

Shortcut for:

bot.copy_message(from_chat_id=update.effective_chat.id, *args, **kwargs)
Returns:On success, instance representing the message posted.
Return type:telegram.Message
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.

Convenience property. If the chat has a username, returns a t.me link of the chat.

Type:str
pin_message(*args, **kwargs) → bool

Shortcut for:

bot.pin_chat_message(chat_id=update.effective_chat.id,
                     *args,
                     **kwargs)
Returns:On success, True is returned.
Return type:bool
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_copy(*args, **kwargs) → MessageId

Shortcut for:

bot.copy_message(chat_id=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
unpin_all_messages(*args, **kwargs) → bool

Shortcut for:

bot.unpin_all_chat_messages(chat_id=update.effective_chat.id,
                            *args,
                            **kwargs)
Returns:On success, True is returned.
Return type:bool
unpin_message(*args, **kwargs) → bool

Shortcut for:

bot.unpin_chat_message(chat_id=update.effective_chat.id,
                       *args,
                       **kwargs)
Returns:On success, True is returned.
Return type:bool