TelegramSDK_php

Chat
in package

Tags
brief

Chat class.

details

This class is used to get information about chats.

Table of Contents

Properties

$chat_id  : int
$chat_obj  : stdClass|null
$title  : string|null
$type  : ChatType
$user  : User|null
$username  : string|null
$chat_obj  : stdClass|null

Methods

__construct()  : mixed
__get()  : mixed
accept_join_request()  : void
create_invite_link()  : string
decline_join_request()  : void
get_administrators()  : array<string|int, mixed>
get_chat_member()  : array<string|int, mixed>
get_invite_link()  : string
get_latest_messages()  : array<string|int, mixed>
get_members_count()  : int
get_permissions()  : stdClass|null
get_profile_picture()  : string
pin_message()  : bool
revoke_invite_link()  : bool
save_chat_from_message()  : void
set_description()  : void
set_permissions()  : void
set_title()  : void
chat_member_to_array()  : array<string|int, mixed>
get_chat()  : stdClass|null

Properties

$chat_id read-only

public int $chat_id

Chat id.

$chat_obj read-only

public stdClass|null $chat_obj

Chat object (as returned by Telegram).

$title read-only

public string|null $title

Chat title.

$user read-only

public User|null $user

User object (if chat is a private chat, otherwise null).

$username read-only

public string|null $username

Chat username.

$chat_obj

private stdClass|null $chat_obj

Methods

__construct()

public __construct(string|int $identifier) : mixed
Parameters
$identifier : string|int

Chat id or username.

Tags
brief

Construct a new Chat object.

throws
Exception

If database is not setup or chat does not exist in database.

__get()

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

Variable name.

Tags
brief

Get protected properties, keeping them protected from being changed.

throws
Exception

If variable does not exist or is not allowed to be accessed externally.

accept_join_request()

public accept_join_request(int $user_id) : void
Parameters
$user_id : int

User id.

Tags
brief

Accept chat join request.

public create_invite_link([int $expire_date = 0 ][, int $member_limit = 0 ][, bool $approval_needed = false ]) : string
Parameters
$expire_date : int = 0

(Optional) Date when the link will expire. Default is 0 (never expires).

$member_limit : int = 0

(Optional) Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999. Default is 0 (unlimited).

$approval_needed : bool = false

(Optional) If users joining the chat via the link need to be approved by chat administrators. If true $member_limit is ignored. Default is false.

Tags
brief

Create a new chat invite link.

Return values
string

decline_join_request()

public decline_join_request(int $user_id) : void
Parameters
$user_id : int

User id.

Tags
brief

Decline chat join request.

get_administrators()

public get_administrators() : array<string|int, mixed>
Tags
brief

Get chat administrators.

Return values
array<string|int, mixed>

get_chat_member()

public get_chat_member() : array<string|int, mixed>
Tags
brief

Get chat member.

Return values
array<string|int, mixed>
public get_invite_link() : string
Tags
brief

Get primary invite link.

Return values
string

get_latest_messages()

public get_latest_messages([int $limit = 100 ]) : array<string|int, mixed>
Parameters
$limit : int = 100

(Optional) Limit of messages to get. Default is 100.

Tags
brief

Get latest messages from chat.

Return values
array<string|int, mixed>

get_members_count()

public get_members_count() : int
Tags
brief

Get chat members count.

Return values
int

get_permissions()

public get_permissions() : stdClass|null
Tags
brief

Get chat permissions.

Return values
stdClass|null

Chat permissions. Docs: https://core.telegram.org/bots/api#chatpermissions

get_profile_picture()

public get_profile_picture([ChatPhotoSize $size = ChatPhotoSize::big ]) : string
Parameters
$size : ChatPhotoSize = ChatPhotoSize::big

(Optional) Size of the profile picture. Default is big.

Tags
brief

Get chat profile picture url. Returns empty string if chat does not have a profile picture.

Note: This function returns a url containing sensitive information. Make sure to protect it and not share with end users.

Return values
string

pin_message()

public pin_message(int $message_id[, bool $disable_notification = false ]) : bool
Parameters
$message_id : int

Message id of the message to pin.

$disable_notification : bool = false

(Optional) Disable notification. Default is false.

Tags
brief

Pin a message.

Return values
bool
public revoke_invite_link(string $invite_link) : bool
Parameters
$invite_link : string

Invite link to revoke.

Tags
brief

Revoke an invite link.

Return values
bool

save_chat_from_message()

public static save_chat_from_message(stdClass $message) : void
Parameters
$message : stdClass

Message object.

Tags
brief

Save chat to database on message.

Note: Shall not be called manually. Is called by Bot class when needed.

set_description()

public set_description(string $description) : void
Parameters
$description : string

New chat description.

Tags
brief

Set chat description.

set_permissions()

public set_permissions(stdClass $permissions) : void
Parameters
$permissions : stdClass

Chat permissions. Docs: https://core.telegram.org/bots/api#chatpermissions

Tags
brief

Set chat permissions.

set_title()

public set_title(string $title) : void
Parameters
$title : string

New chat title.

Tags
brief

Set chat title.

chat_member_to_array()

private chat_member_to_array(stdClass $member_obj) : array<string|int, mixed>
Parameters
$member_obj : stdClass

Member object.

Tags
brief

Convert Chat member object to array.

Return values
array<string|int, mixed>

get_chat()

private get_chat() : stdClass|null
Tags
brief

Get chat object from Telegram API.

Return values
stdClass|null

        
On this page

Search results