PhpBotFramework  2.0.2
A framework for Telegram Bots' APIs.
Functions | Variables
Users handling

Handle bot users on the database. More...

Functions

bool PhpBotFramework\Database\User::addUser ($chat_id)
 Add a user to the database. More...
 
int PhpBotFramework\Database\User::broadcastMessage (string $text, string $reply_markup=null, string $parse_mode='HTML', bool $disable_web_preview=true, bool $disable_notification=false)
 Send a message to every user available on the database. More...
 

Variables

 PhpBotFramework\Database\User::$user_table = 'User'
 Table contaning bot users data in the SQL database.
 
 PhpBotFramework\Database\User::$id_column = 'chat_id'
 Name of the column that represents the user id in the sql database.
 

Detailed Description

Handle bot users on the database.

Function Documentation

◆ addUser()

bool PhpBotFramework\Database\User::addUser (   $chat_id)

Add a user to the database.

Add a user to the database in Bot::$user_table table and Bot::$id_column column using Bot::$pdo connection.

Parameters
string | int$chat_idchat ID of the user to add.
Returns
bool True on success.

◆ broadcastMessage()

int PhpBotFramework\Database\User::broadcastMessage ( string  $text,
string  $reply_markup = null,
string  $parse_mode = 'HTML',
bool  $disable_web_preview = true,
bool  $disable_notification = false 
)

Send a message to every user available on the database.

Send a message to all subscribed users, change Bot::$user_table and Bot::$id_column to match your database structure. This method requires Bot::$pdo connection set. All parameters are the same as CoreBot::sendMessage. Because a limitation of Telegram Bot API the bot will have a delay after 20 messages sent in different chats.

Returns
int How many messages were sent.
See also
CoreBot::sendMessage