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.
Datei anzeigen Open project: akalongman/php-telegram-bot Class Usage Examples

Public Properties

Property Type Description
$notes array Notes to be stored

Protected Properties

Property 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

Public Methods

Method 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

Protected Methods

Method 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 method

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 method

Cancel the current conversation
public cancel ( ) : boolean
return boolean

clear() protected method

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

exists() public method

Check if the conversation already exists
public exists ( ) : boolean
return boolean

getCommand() public method

Retrieve the command to execute from the conversation
public getCommand ( ) : string | null
return string | null

load() protected method

Load the conversation from the database
protected load ( ) : boolean
return boolean

start() protected method

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

stop() public method

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

update() public method

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

updateStatus() protected method

Update the status of the current conversation
protected updateStatus ( string $status ) : boolean
$status string
return boolean

Property Details

$chat_id protected_oe property

Telegram chat id
protected int $chat_id
return integer

$command protected_oe property

Command to be executed if the conversation is active
protected string $command
return string

$conversation protected_oe property

All information fetched from the database
protected array $conversation
return array

$notes public_oe property

Notes to be stored
public array $notes
return array

$protected_notes protected_oe property

Notes stored inside the conversation
protected array $protected_notes
return array

$user_id protected_oe property

Telegram user id
protected int $user_id
return integer