TelegramPHP Documentation

Chat extends Part
in package
uses ChatBehaviour

This file is generated from spec/openapi.json (Bot API 10.3) by tools/generate.php.

Do not edit it by hand - run composer spec:build instead.

This object represents a chat.

Tags
link
https://core.telegram.org/bots/api#chat
since

v10.3

Table of Contents

Constants

DISCRIMINATOR  : mixed = null
The attribute whose value names the concrete subtype, for union parents.
SUBTYPES  : array<string, Part>>|array<int, Part>> = []
The concrete classes a union parent may resolve to - keyed by discriminator value when there is one, a plain list otherwise. Empty on ordinary parts.

Properties

$first_name  : string|null
$id  : int
$is_direct_messages  : bool|null
$is_forum  : bool|null
$last_name  : string|null
$title  : string|null
$type  : string
$username  : string|null
$casts  : array<string, string>
Attribute name => Telegram type token ("User", "Array of PhotoSize"), used to hydrate nested objects into parts.
$dates  : array<int, string>
Attribute names holding Unix timestamps, read back as {@see CarbonImmutable}.
$fillable  : array<int, string>
Attribute names this part accepts. Empty = accept anything.
$telegram  : Telegram

Methods

__construct()  : mixed
__debugInfo()  : array<string, mixed>
__get()  : mixed
__isset()  : bool
__set()  : void
__toString()  : string
attributeExists()  : bool
ban()  : PromiseInterface<string|int, bool>
Bans a user, optionally until a point in time.
countMembers()  : PromiseInterface<string|int, int>
How many members this chat has.
fetch()  : PromiseInterface<string|int, ChatFullInfo>
The full record for this chat, which carries far more than the stub an update brings along.
fill()  : void
getAttribute()  : mixed
getCasts()  : array<string, string>
getFillable()  : array<int, string>
getMember()  : PromiseInterface<string|int, ChatMember>
One member of this chat.
getRawAttributes()  : array<string, mixed>
getTelegram()  : Telegram
jsonSerialize()  : array<string, mixed>
The payload this part would be sent back to Telegram as - nested parts and collections flattened, timestamps left as the integers they arrived as.
leave()  : PromiseInterface<string|int, bool>
Leaves this chat.
offsetExists()  : bool
offsetGet()  : mixed
offsetSet()  : void
offsetUnset()  : void
resolveSubtype()  : Part>
The concrete class an incoming payload belongs to, for a union parent.
sendAction()  : PromiseInterface<string|int, bool>
Shows "typing...", "sending photo...", and the rest, for a few seconds.
sendMessage()  : PromiseInterface<string|int, Message>
Sends a message to this chat.
sendPhoto()  : PromiseInterface<string|int, Message>
Sends a photo to this chat.
setAttribute()  : void
unban()  : PromiseInterface<string|int, bool>
Lifts a ban.
factory()  : Factory
Builds another part from the same client - for nested objects.
getRawAttribute()  : mixed
Reads straight from the attribute bag, skipping the `get{Key}Attribute` hook.
setRawAttribute()  : void
Writes straight to the attribute bag, skipping the `set{Key}Attribute` hook and any cast. For use *inside* a mutator, which would otherwise have no way to store its shaped value without recursing through {@see setAttribute()}.

Constants

DISCRIMINATOR

The attribute whose value names the concrete subtype, for union parents.

public mixed DISCRIMINATOR = null

null on ordinary parts and on unions Telegram does not tag.

SUBTYPES

The concrete classes a union parent may resolve to - keyed by discriminator value when there is one, a plain list otherwise. Empty on ordinary parts.

public array<string, Part>>|array<int, Part>> SUBTYPES = []

Properties

$first_name

public string|null $first_name

Optional. First name of the other party in a private chat

$id

public int $id

Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.

$is_direct_messages

public bool|null $is_direct_messages

Optional. True, if the chat is the direct messages chat of a channel

$is_forum

public bool|null $is_forum

Optional. True, if the supergroup chat is a forum (has topics enabled)

$last_name

public string|null $last_name

Optional. Last name of the other party in a private chat

$title

public string|null $title

Optional. Title, for supergroups, channels and group chats

$type

public string $type

Type of the chat, can be either "private", "group", "supergroup" or "channel"

$username

public string|null $username

Optional. Username, for private chats, supergroups and channels if available

$casts

Attribute name => Telegram type token ("User", "Array of PhotoSize"), used to hydrate nested objects into parts.

protected array<string, string> $casts = []

$dates

Attribute names holding Unix timestamps, read back as {@see CarbonImmutable}.

protected array<int, string> $dates = []

$fillable

Attribute names this part accepts. Empty = accept anything.

protected array<int, string> $fillable = ['id', 'type', 'title', 'username', 'first_name', 'last_name', 'is_forum', 'is_direct_messages']

Methods

__construct()

public __construct(Telegram $telegram[, array<string, mixed>|object $attributes = [] ]) : mixed
Parameters
$telegram : Telegram
$attributes : array<string, mixed>|object = []

__debugInfo()

public __debugInfo() : array<string, mixed>
Return values
array<string, mixed>

__get()

public __get(string $name) : mixed
Parameters
$name : string

__isset()

public __isset(string $name) : bool
Parameters
$name : string
Return values
bool

__set()

public __set(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed

__toString()

public __toString() : string
Return values
string

attributeExists()

public attributeExists(string $key) : bool
Parameters
$key : string
Return values
bool

ban()

Bans a user, optionally until a point in time.

public ban(int $userId[, array<string, mixed> $options = [] ]) : PromiseInterface<string|int, bool>
Parameters
$userId : int
$options : array<string, mixed> = []

Any other banChatMember field.

Return values
PromiseInterface<string|int, bool>

countMembers()

How many members this chat has.

public countMembers() : PromiseInterface<string|int, int>
Return values
PromiseInterface<string|int, int>

fetch()

The full record for this chat, which carries far more than the stub an update brings along.

public fetch() : PromiseInterface<string|int, ChatFullInfo>
Return values
PromiseInterface<string|int, ChatFullInfo>

fill()

public fill(array<string, mixed> $attributes) : void
Parameters
$attributes : array<string, mixed>

getAttribute()

public getAttribute(string $key) : mixed
Parameters
$key : string

getCasts()

public getCasts() : array<string, string>
Return values
array<string, string>

getFillable()

public getFillable() : array<int, string>
Return values
array<int, string>

getMember()

One member of this chat.

public getMember(int $userId) : PromiseInterface<string|int, ChatMember>
Parameters
$userId : int
Return values
PromiseInterface<string|int, ChatMember>

getRawAttributes()

public getRawAttributes() : array<string, mixed>
Return values
array<string, mixed>

jsonSerialize()

The payload this part would be sent back to Telegram as - nested parts and collections flattened, timestamps left as the integers they arrived as.

public jsonSerialize() : array<string, mixed>
Return values
array<string, mixed>

leave()

Leaves this chat.

public leave() : PromiseInterface<string|int, bool>
Return values
PromiseInterface<string|int, bool>

offsetExists()

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool

offsetGet()

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed

offsetSet()

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed
$value : mixed

offsetUnset()

public offsetUnset(mixed $offset) : void
Parameters
$offset : mixed

resolveSubtype()

The concrete class an incoming payload belongs to, for a union parent.

public static resolveSubtype(array<string, mixed> $attributes) : Part>

Tagged unions resolve on their discriminator. The handful Telegram leaves untagged (InputMessageContent, and the rest), and any payload whose tag this build does not recognise - a member added to the Bot API since it was generated - resolve instead to the subtype whose attributes the payload matches most closely.

Parameters
$attributes : array<string, mixed>
Tags
throws
PartException

When the part is not a union, or nothing matches.

Return values
Part>

sendAction()

Shows "typing...", "sending photo...", and the rest, for a few seconds.

public sendAction([string $action = 'typing' ]) : PromiseInterface<string|int, bool>
Parameters
$action : string = 'typing'
Return values
PromiseInterface<string|int, bool>

sendMessage()

Sends a message to this chat.

public sendMessage(string $text[, array<string, mixed> $options = [] ]) : PromiseInterface<string|int, Message>
Parameters
$text : string
$options : array<string, mixed> = []

Any other sendMessage field.

Return values
PromiseInterface<string|int, Message>

sendPhoto()

Sends a photo to this chat.

public sendPhoto(InputFile|string $photo[, array<string, mixed> $options = [] ]) : PromiseInterface<string|int, Message>
Parameters
$photo : InputFile|string
$options : array<string, mixed> = []

Any other sendPhoto field.

Return values
PromiseInterface<string|int, Message>

setAttribute()

public setAttribute(string $key, mixed $value) : void
Parameters
$key : string
$value : mixed

unban()

Lifts a ban.

public unban(int $userId[, bool $onlyIfBanned = true ]) : PromiseInterface<string|int, bool>
Parameters
$userId : int
$onlyIfBanned : bool = true
Return values
PromiseInterface<string|int, bool>

factory()

Builds another part from the same client - for nested objects.

protected factory() : Factory
Return values
Factory

getRawAttribute()

Reads straight from the attribute bag, skipping the `get{Key}Attribute` hook.

protected getRawAttribute(string $key) : mixed
Parameters
$key : string

setRawAttribute()

Writes straight to the attribute bag, skipping the `set{Key}Attribute` hook and any cast. For use *inside* a mutator, which would otherwise have no way to store its shaped value without recursing through {@see setAttribute()}.

protected setRawAttribute(string $key, mixed $value) : void
Parameters
$key : string
$value : mixed
On this page

Search results