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
$bot read-only
public
Bot|null
$bot
= null
$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
staticban()
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
BanChatMemberbanSenderChat()
public
banSenderChat(int $senderChatId) : BanChatSenderChat
Parameters
- $senderChatId : int
Return values
BanChatSenderChatcreateInviteLink()
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
CreateChatInviteLinkdeleteMessage()
public
deleteMessage(int $messageId) : DeleteMessage
Parameters
- $messageId : int
Return values
DeleteMessagedeletePhoto()
public
deletePhoto() : DeleteChatPhoto
Return values
DeleteChatPhotodeleteStickerSet()
public
deleteStickerSet() : DeleteChatStickerSet
Return values
DeleteChatStickerSetdo()
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
SendChatActioneditInviteLink()
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
EditChatInviteLinkexportInviteLink()
public
exportInviteLink() : ExportChatInviteLink
Return values
ExportChatInviteLinkfullName()
public
fullName() : string
Return values
stringgetAdministrators()
public
getAdministrators([bool|null $returnBots = null ]) : GetChatAdministrators
Parameters
- $returnBots : bool|null = null
Return values
GetChatAdministratorsgetMember()
public
getMember(int $userId) : GetChatMember
Parameters
- $userId : int
Return values
GetChatMembergetMemberCount()
public
getMemberCount() : GetChatMemberCount
Return values
GetChatMemberCountleave()
public
leave() : LeaveChat
Return values
LeaveChatpinMessage()
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
PinChatMessagepromote()
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
PromoteChatMemberrestrict()
public
restrict(int $userId, ChatPermissions $permissions[, bool|null $useIndependentChatPermissions = null ][, DateInterval|DateTime|int|null $untilDate = null ]) : RestrictChatMember
Parameters
- $userId : int
- $permissions : ChatPermissions
- $useIndependentChatPermissions : bool|null = null
- $untilDate : DateInterval|DateTime|int|null = null
Return values
RestrictChatMemberrevokeInviteLink()
public
revokeInviteLink(string $inviteLink) : RevokeChatInviteLink
Parameters
- $inviteLink : string
Return values
RevokeChatInviteLinksetAdministratorCustomTitle()
public
setAdministratorCustomTitle(int $userId, string $customTitle) : SetChatAdministratorCustomTitle
Parameters
- $userId : int
- $customTitle : string
Return values
SetChatAdministratorCustomTitlesetDescription()
public
setDescription([string|null $description = null ]) : SetChatDescription
Parameters
- $description : string|null = null
Return values
SetChatDescriptionsetMemberTag()
public
setMemberTag(int $userId[, string|null $tag = null ]) : SetChatMemberTag
Parameters
- $userId : int
- $tag : string|null = null
Return values
SetChatMemberTagsetPermissions()
public
setPermissions(ChatPermissions $permissions[, bool|null $useIndependentChatPermissions = null ]) : SetChatPermissions
Parameters
- $permissions : ChatPermissions
- $useIndependentChatPermissions : bool|null = null
Return values
SetChatPermissionssetPhoto()
public
setPhoto(InputFile $photo) : SetChatPhoto
Parameters
- $photo : InputFile
Return values
SetChatPhotosetStickerSet()
public
setStickerSet(string $stickerSetName) : SetChatStickerSet
Parameters
- $stickerSetName : string
Return values
SetChatStickerSetsetTitle()
public
setTitle(string $title) : SetChatTitle
Parameters
- $title : string
Return values
SetChatTitleunban()
public
unban(int $userId[, bool|null $onlyIfBanned = null ]) : UnbanChatMember
Parameters
- $userId : int
- $onlyIfBanned : bool|null = null
Return values
UnbanChatMemberunbanSenderChat()
public
unbanSenderChat(int $senderChatId) : UnbanChatSenderChat
Parameters
- $senderChatId : int
Return values
UnbanChatSenderChatunpinAllGeneralForumTopicMessages()
public
unpinAllGeneralForumTopicMessages() : UnpinAllGeneralForumTopicMessages
Return values
UnpinAllGeneralForumTopicMessagesunpinAllMessages()
public
unpinAllMessages() : UnpinAllChatMessages
Return values
UnpinAllChatMessagesunpinMessage()
public
unpinMessage([string|null $businessConnectionId = null ][, int|null $messageId = null ]) : UnpinChatMessage
Parameters
- $businessConnectionId : string|null = null
- $messageId : int|null = null
Return values
UnpinChatMessagewithBot()
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