Conversation
in package
Class 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.
Table of Contents
- $notes : mixed
- Notes to be stored
- $chat_id : int
- Telegram chat id
- $command : string
- Command to be executed if the conversation is active
- $conversation : array<string|int, mixed>|null
- All information fetched from the database
- $protected_notes : mixed
- Notes stored inside the conversation
- $user_id : int
- Telegram user id
- __construct() : mixed
- Conversation contructor to initialize a new conversation
- cancel() : bool
- Cancel the current conversation
- exists() : bool
- Check if the conversation already exists
- getCommand() : string|null
- Retrieve the command to execute from the conversation
- stop() : bool
- Delete the current conversation
- update() : bool
- Store the array/variable in the database with json_encode() function
- clear() : bool
- Clear all conversation variables.
- load() : bool
- Load the conversation from the database
- start() : bool
- Start a new conversation if the current command doesn't have one yet
- updateStatus() : bool
- Update the status of the current conversation
Properties
$notes
Notes to be stored
public
mixed
$notes
$chat_id
Telegram chat id
protected
int
$chat_id
$command
Command to be executed if the conversation is active
protected
string
$command
$conversation
All information fetched from the database
protected
array<string|int, mixed>|null
$conversation
$protected_notes
Notes stored inside the conversation
protected
mixed
$protected_notes
$user_id
Telegram user id
protected
int
$user_id
Methods
__construct()
Conversation contructor to initialize a new conversation
public
__construct(int $user_id, int $chat_id[, string $command = null ]) : mixed
Parameters
- $user_id : int
- $chat_id : int
- $command : string = null
Tags
Return values
mixed —cancel()
Cancel the current conversation
public
cancel() : bool
Return values
bool —exists()
Check if the conversation already exists
public
exists() : bool
Return values
bool —getCommand()
Retrieve the command to execute from the conversation
public
getCommand() : string|null
Return values
string|null —stop()
Delete the current conversation
public
stop() : bool
Currently the Conversation is not deleted but just set to 'stopped'
Return values
bool —update()
Store the array/variable in the database with json_encode() function
public
update() : bool
Return values
bool —clear()
Clear all conversation variables.
protected
clear() : bool
Return values
bool —Always return true, to allow this method in an if statement.
load()
Load the conversation from the database
protected
load() : bool
Tags
Return values
bool —start()
Start a new conversation if the current command doesn't have one yet
protected
start() : bool
Tags
Return values
bool —updateStatus()
Update the status of the current conversation
protected
updateStatus(string $status) : bool
Parameters
- $status : string