TelegramPHP Documentation

UserBehaviour

Conveniences for a user part: how to name them, and how to write to them.

A bot can only message a user who has started a conversation with it, so sendMessage() rejects with a 403 when they have not.

Tags
author

Valithor Obsidion valithor@valgorithms.com

Table of Contents

Methods

getFullName()  : string
First and last name, joined - the name Telegram shows.
getHandle()  : string
`@username` when they have one, their display name otherwise.
getProfilePhotos()  : PromiseInterface<string|int, UserProfilePhotos>
This user's profile photos.
mention()  : string
A Markdown or HTML mention that links to this user, which works even when they have no username.
sendMessage()  : PromiseInterface<string|int, Message>
Messages this user directly.

Methods

getFullName()

First and last name, joined - the name Telegram shows.

public getFullName() : string
Return values
string

getHandle()

`@username` when they have one, their display name otherwise.

public getHandle() : string
Return values
string

getProfilePhotos()

This user's profile photos.

public getProfilePhotos([?int $offset = null ][, ?int $limit = null ]) : PromiseInterface<string|int, UserProfilePhotos>
Parameters
$offset : ?int = null
$limit : ?int = null
Return values
PromiseInterface<string|int, UserProfilePhotos>

mention()

A Markdown or HTML mention that links to this user, which works even when they have no username.

public mention([string $parseMode = 'HTML' ]) : string
Parameters
$parseMode : string = 'HTML'
Return values
string

sendMessage()

Messages this user directly.

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>
On this page

Search results