PHP Class 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.
Afficher le fichier Open project: akalongman/php-telegram-bot Class Usage Examples

Méthodes publiques

Свойство Type Description
$notes array Notes to be stored

Protected Properties

Свойство Type Description
$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

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
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

Method Details

__construct() public méthode

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() public méthode

Cancel the current conversation
public cancel ( ) : boolean
Résultat boolean

clear() protected méthode

Clear all conversation variables.
protected clear ( ) : boolean
Résultat boolean Always return true, to allow this method in an if statement.

exists() public méthode

Check if the conversation already exists
public exists ( ) : boolean
Résultat boolean

getCommand() public méthode

Retrieve the command to execute from the conversation
public getCommand ( ) : string | null
Résultat string | null

load() protected méthode

Load the conversation from the database
protected load ( ) : boolean
Résultat boolean

start() protected méthode

Start a new conversation if the current command doesn't have one yet
protected start ( ) : boolean
Résultat boolean

stop() public méthode

Currently the Conversation is not deleted but just set to 'stopped'
public stop ( ) : boolean
Résultat boolean

update() public méthode

Store the array/variable in the database with json_encode() function
public update ( ) : boolean
Résultat boolean

updateStatus() protected méthode

Update the status of the current conversation
protected updateStatus ( string $status ) : boolean
$status string
Résultat boolean

Property Details

$chat_id protected_oe property

Telegram chat id
protected int $chat_id
Résultat integer

$command protected_oe property

Command to be executed if the conversation is active
protected string $command
Résultat string

$conversation protected_oe property

All information fetched from the database
protected array $conversation
Résultat array

$notes public_oe property

Notes to be stored
public array $notes
Résultat array

$protected_notes protected_oe property

Notes stored inside the conversation
protected array $protected_notes
Résultat array

$user_id protected_oe property

Telegram user id
protected int $user_id
Résultat integer