phpbotgram

Chat extends TelegramObject
in package
uses ChatShortcuts

This object represents a chat.

Source: https://core.telegram.org/bots/api#chat

Table of Contents

Properties

$bot  : Bot|null
$firstName  : string|null
$id  : int
$isDirectMessages  : bool|null
$isForum  : bool|null
$lastName  : string|null
$title  : string|null
$type  : string
$username  : string|null

Methods

__construct()  : mixed
as_()  : static
Alias of withBot() for grep-translating aiogram code that uses obj.as_(bot).
ban()  : BanChatMember
banSenderChat()  : BanChatSenderChat
createInviteLink()  : CreateChatInviteLink
deleteMessage()  : DeleteMessage
deletePhoto()  : DeleteChatPhoto
deleteStickerSet()  : DeleteChatStickerSet
do()  : SendChatAction
editInviteLink()  : EditChatInviteLink
exportInviteLink()  : ExportChatInviteLink
fullName()  : string
getAdministrators()  : GetChatAdministrators
getMember()  : GetChatMember
getMemberCount()  : GetChatMemberCount
leave()  : LeaveChat
pinMessage()  : PinChatMessage
promote()  : PromoteChatMember
restrict()  : RestrictChatMember
revokeInviteLink()  : RevokeChatInviteLink
setAdministratorCustomTitle()  : SetChatAdministratorCustomTitle
setDescription()  : SetChatDescription
setMemberTag()  : SetChatMemberTag
setPermissions()  : SetChatPermissions
setPhoto()  : SetChatPhoto
setStickerSet()  : SetChatStickerSet
setTitle()  : SetChatTitle
unban()  : UnbanChatMember
unbanSenderChat()  : UnbanChatSenderChat
unpinAllGeneralForumTopicMessages()  : UnpinAllGeneralForumTopicMessages
unpinAllMessages()  : UnpinAllChatMessages
unpinMessage()  : UnpinChatMessage
withBot()  : static
Returns a clone of $this with $bot rebound recursively. Walks every public property; nested `BotContextController` instances are rebound via their own `withBot`, arrays (including nested arrays of arbitrary depth — e.g.

Properties

$firstName read-only

public string|null $firstName = null

$id read-only

public int $id

$isDirectMessages read-only

public bool|null $isDirectMessages = null

$isForum read-only

public bool|null $isForum = null

$lastName read-only

public string|null $lastName = null

$title read-only

public string|null $title = null

$type read-only

public string $type

$username read-only

public string|null $username = null

Methods

__construct()

public __construct(int $id, string $type[, string|null $title = null ][, string|null $username = null ][, string|null $firstName = null ][, string|null $lastName = null ][, bool|null $isForum = null ][, bool|null $isDirectMessages = null ][, Bot|null $bot = null ]) : mixed
Parameters
$id : int
$type : string
$title : string|null = null
$username : string|null = null
$firstName : string|null = null
$lastName : string|null = null
$isForum : bool|null = null
$isDirectMessages : bool|null = null
$bot : Bot|null = null

as_()

Alias of withBot() for grep-translating aiogram code that uses obj.as_(bot).

public as_(Bot|null $bot) : static

IMPORTANT: behaves DIFFERENTLY from upstream — upstream mutates self.bot in place and returns self. The PHP port can't mutate readonly, so this returns a clone. Callers must reassign: $msg = $msg->as($bot).

Parameters
$bot : Bot|null
Return values
static

ban()

public ban(int $userId[, DateInterval|DateTime|int|null $untilDate = null ][, bool|null $revokeMessages = null ]) : BanChatMember
Parameters
$userId : int
$untilDate : DateInterval|DateTime|int|null = null
$revokeMessages : bool|null = null
Return values
BanChatMember
public createInviteLink([string|null $name = null ][, DateInterval|DateTime|int|null $expireDate = null ][, int|null $memberLimit = null ][, bool|null $createsJoinRequest = null ]) : CreateChatInviteLink
Parameters
$name : string|null = null
$expireDate : DateInterval|DateTime|int|null = null
$memberLimit : int|null = null
$createsJoinRequest : bool|null = null
Return values
CreateChatInviteLink

do()

public do(string $action[, string|null $businessConnectionId = null ][, int|null $messageThreadId = null ]) : SendChatAction
Parameters
$action : string
$businessConnectionId : string|null = null
$messageThreadId : int|null = null
Return values
SendChatAction
public editInviteLink(string $inviteLink[, string|null $name = null ][, DateInterval|DateTime|int|null $expireDate = null ][, int|null $memberLimit = null ][, bool|null $createsJoinRequest = null ]) : EditChatInviteLink
Parameters
$inviteLink : string
$name : string|null = null
$expireDate : DateInterval|DateTime|int|null = null
$memberLimit : int|null = null
$createsJoinRequest : bool|null = null
Return values
EditChatInviteLink

pinMessage()

public pinMessage(int $messageId[, string|null $businessConnectionId = null ][, bool|null $disableNotification = null ]) : PinChatMessage
Parameters
$messageId : int
$businessConnectionId : string|null = null
$disableNotification : bool|null = null
Return values
PinChatMessage

promote()

public promote(int $userId[, bool|null $isAnonymous = null ][, bool|null $canManageChat = null ][, bool|null $canDeleteMessages = null ][, bool|null $canManageVideoChats = null ][, bool|null $canRestrictMembers = null ][, bool|null $canPromoteMembers = null ][, bool|null $canChangeInfo = null ][, bool|null $canInviteUsers = null ][, bool|null $canPostStories = null ][, bool|null $canEditStories = null ][, bool|null $canDeleteStories = null ][, bool|null $canPostMessages = null ][, bool|null $canEditMessages = null ][, bool|null $canPinMessages = null ][, bool|null $canManageTopics = null ][, bool|null $canManageDirectMessages = null ][, bool|null $canManageTags = null ]) : PromoteChatMember
Parameters
$userId : int
$isAnonymous : bool|null = null
$canManageChat : bool|null = null
$canDeleteMessages : bool|null = null
$canManageVideoChats : bool|null = null
$canRestrictMembers : bool|null = null
$canPromoteMembers : bool|null = null
$canChangeInfo : bool|null = null
$canInviteUsers : bool|null = null
$canPostStories : bool|null = null
$canEditStories : bool|null = null
$canDeleteStories : bool|null = null
$canPostMessages : bool|null = null
$canEditMessages : bool|null = null
$canPinMessages : bool|null = null
$canManageTopics : bool|null = null
$canManageDirectMessages : bool|null = null
$canManageTags : bool|null = null
Return values
PromoteChatMember

unban()

public unban(int $userId[, bool|null $onlyIfBanned = null ]) : UnbanChatMember
Parameters
$userId : int
$onlyIfBanned : bool|null = null
Return values
UnbanChatMember

unpinMessage()

public unpinMessage([string|null $businessConnectionId = null ][, int|null $messageId = null ]) : UnpinChatMessage
Parameters
$businessConnectionId : string|null = null
$messageId : int|null = null
Return values
UnpinChatMessage

withBot()

Returns a clone of $this with $bot rebound recursively. Walks every public property; nested `BotContextController` instances are rebound via their own `withBot`, arrays (including nested arrays of arbitrary depth — e.g.

public withBot(Bot|null $bot) : static

list<list<KeyboardButton>>) are walked element-wise. Plain values (scalars, DateTime, enums, InputFile etc.) pass through untouched.

Mirrors upstream pydantic model_validate(context={"bot": bot}) (aiogram ContextController.as_/model_dump_json+model_validate).

Scope note: PHP 8.5 treats public readonly as effectively public protected(set) readonly for clone-with — only code running with a scope in the property's declaring class hierarchy (declaring class plus its ancestors and descendants) can use clone($obj, ['x' => ...]) against it. Because this method lives on BotContextController and every TelegramObject/TelegramMethod subclass extends it, the walker's clone($this, [...]) call legally rewrites subclass-declared readonly slots like Message::$chat. External callers cannot use the same syntax — they must funnel through this method.

Parameters
$bot : Bot|null
Return values
static
On this page

Search results