telegram.Chat

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

Bases: telegram.base.TelegramObject

This object represents a chat.

id

int – Unique identifier for this chat.

type

str – Type of chat.

title

str – Optional. Title, for supergroups, channels and group chats.

username

str – Optional. Username.

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.

all_members_are_administrators

bool – Optional.

photo

telegram.ChatPhoto – Optional. Chat photo.

description

str – Optional. Description, for supergroups and channel chats.

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

pinned_message

telegram.Message – Optional. Pinned message, for supergroups. Returned only in get_chat.

sticker_set_name

str – Optional. For supergroups, name of Group sticker set.

can_set_sticker_set

bool – Optional. True, if the bot can change group the sticker set.

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.
  • all_members_are_administrators (bool, optional) – True if a group has All Members Are Admins enabled.
  • photo (telegram.ChatPhoto, optional) – Chat photo. Returned only in getChat.
  • description (str, optional) – Description, for 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.
  • 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'

str – ‘channel’

GROUP = 'group'

str – ‘group’

PRIVATE = 'private'

str – ‘private’

SUPERGROUP = 'supergroup'

str – ‘supergroup’

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.
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
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