PHP Класс Longman\TelegramBot\Conversation

Only one conversation can be active at any one time. A conversation is directly linked to a user, chat and the command that is managing the conversation.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$notes array Notes to be stored

Защищенные свойства (Protected)

Свойство Тип Описание
$chat_id integer Telegram chat id
$command string Command to be executed if the conversation is active
$conversation array All information fetched from the database
$protected_notes array Notes stored inside the conversation
$user_id integer Telegram user id

Открытые методы

Метод Описание
__construct ( integer $user_id, integer $chat_id, string $command = null ) Conversation contructor to initialize a new conversation
cancel ( ) : boolean Cancel the current conversation
exists ( ) : boolean Check if the conversation already exists
getCommand ( ) : string | null Retrieve the command to execute from the conversation
stop ( ) : boolean Delete the current conversation
update ( ) : boolean Store the array/variable in the database with json_encode() function

Защищенные методы

Метод Описание
clear ( ) : boolean Clear all conversation variables.
load ( ) : boolean Load the conversation from the database
start ( ) : boolean Start a new conversation if the current command doesn't have one yet
updateStatus ( string $status ) : boolean Update the status of the current conversation

Описание методов

__construct() публичный Метод

Conversation contructor to initialize a new conversation
public __construct ( integer $user_id, integer $chat_id, string $command = null )
$user_id integer
$chat_id integer
$command string

cancel() публичный Метод

Cancel the current conversation
public cancel ( ) : boolean
Результат boolean

clear() защищенный Метод

Clear all conversation variables.
protected clear ( ) : boolean
Результат boolean Always return true, to allow this method in an if statement.

exists() публичный Метод

Check if the conversation already exists
public exists ( ) : boolean
Результат boolean

getCommand() публичный Метод

Retrieve the command to execute from the conversation
public getCommand ( ) : string | null
Результат string | null

load() защищенный Метод

Load the conversation from the database
protected load ( ) : boolean
Результат boolean

start() защищенный Метод

Start a new conversation if the current command doesn't have one yet
protected start ( ) : boolean
Результат boolean

stop() публичный Метод

Currently the Conversation is not deleted but just set to 'stopped'
public stop ( ) : boolean
Результат boolean

update() публичный Метод

Store the array/variable in the database with json_encode() function
public update ( ) : boolean
Результат boolean

updateStatus() защищенный Метод

Update the status of the current conversation
protected updateStatus ( string $status ) : boolean
$status string
Результат boolean

Описание свойств

$chat_id защищенное свойство

Telegram chat id
protected int $chat_id
Результат integer

$command защищенное свойство

Command to be executed if the conversation is active
protected string $command
Результат string

$conversation защищенное свойство

All information fetched from the database
protected array $conversation
Результат array

$notes публичное свойство

Notes to be stored
public array $notes
Результат array

$protected_notes защищенное свойство

Notes stored inside the conversation
protected array $protected_notes
Результат array

$user_id защищенное свойство

Telegram user id
protected int $user_id
Результат integer