telegram.Chat

class telegram.Chat(id, type, title=None, username=None, first_name=None, last_name=None, bot=None, photo=None, description=None, invite_link=None, pinned_message=None, permissions=None, sticker_set_name=None, can_set_sticker_set=None, slow_mode_delay=None, **kwargs)

Bases: telegram.base.TelegramObject

This object represents a chat.

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

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

Type:str
pinned_message

Optional. Pinned message, for supergroups. Returned only in get_chat.

Type:telegram.Message
permissions

Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat.

Type:telegram.ChatPermission
slow_mode_delay

Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user. Returned only in getChat.

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 in getChat.
  • description (str, optional) – Description, for groups, supergroups and channel chats. Returned only in get_chat.
  • invite_link (str, optional) – Chat invite link, for supergroups and channel chats. Returned only in get_chat.
  • pinned_message (telegram.Message, optional) – Pinned message, for supergroups. Returned only in get_chat.
  • permissions (telegram.ChatPermission) – Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat.
  • slow_mode_delay (int, optional) – For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user. Returned only in getChat.
  • 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 get_chat.
  • can_set_sticker_set (bool, optional) – True, if the bot can change group the sticker set. Returned only in 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)

Shortcut for:

bot.get_chat_administrators(update.message.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)

Shortcut for:

bot.get_chat_member(update.message.chat.id, *args, **kwargs)
Returns:telegram.ChatMember
get_members_count(*args, **kwargs)

Shortcut for:

bot.get_chat_members_count(update.message.chat.id, *args, **kwargs)
Returns:int
kick_member(*args, **kwargs)

Shortcut for:

bot.kick_chat_member(update.message.chat.id, *args, **kwargs)
Returns:If the action was sent succesfully.
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)

Shortcut for:

bot.leave_chat(update.message.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
send_action(*args, **kwargs)

Shortcut for:

bot.send_chat_action(update.message.chat.id, *args, **kwargs)
Returns:If the action was sent successfully.
Return type:bool
send_animation(*args, **kwargs)

Shortcut for:

bot.send_animation(Chat.id, *args, **kwargs)

Where Chat is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_audio(*args, **kwargs)

Shortcut for:

bot.send_audio(Chat.id, *args, **kwargs)

Where Chat is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_document(*args, **kwargs)

Shortcut for:

bot.send_document(Chat.id, *args, **kwargs)

Where Chat is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_message(*args, **kwargs)

Shortcut for:

bot.send_message(Chat.id, *args, **kwargs)

Where Chat is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_photo(*args, **kwargs)

Shortcut for:

bot.send_photo(Chat.id, *args, **kwargs)

Where Chat is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_poll(*args, **kwargs)

Shortcut for:

bot.send_poll(Chat.id, *args, **kwargs)

Where Chat is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_sticker(*args, **kwargs)

Shortcut for:

bot.send_sticker(Chat.id, *args, **kwargs)

Where Chat is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_video(*args, **kwargs)

Shortcut for:

bot.send_video(Chat.id, *args, **kwargs)

Where Chat is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_video_note(*args, **kwargs)

Shortcut for:

bot.send_video_note(Chat.id, *args, **kwargs)

Where Chat is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
send_voice(*args, **kwargs)

Shortcut for:

bot.send_voice(Chat.id, *args, **kwargs)

Where Chat is the current instance.

Returns:On success, instance representing the message posted.
Return type:telegram.Message
set_administrator_custom_title(*args, **kwargs)

Shortcut for:

bot.set_chat_administrator_custom_title(update.message.chat.id, *args, **kwargs)

Returns: bool: If the action was sent successfully.

set_permissions(*args, **kwargs)

Shortcut for:

bot.set_chat_permissions(update.message.chat.id, *args, **kwargs)

Returns: bool: If the action was sent successfully.

unban_member(*args, **kwargs)

Shortcut for:

bot.unban_chat_member(update.message.chat.id, *args, **kwargs)
Returns:If the action was sent successfully.
Return type:bool