-
Notifications
You must be signed in to change notification settings - Fork 0
Init class
Giuseppe Trivisano edited this page May 16, 2025
·
9 revisions
After completing the installation of the framework, every bot request (for example, a message sent to the bot) will initially go to the hook.php file. This file contains the autoloaders, to automatically load every file in the project, and the following method call:
// inside file hook.php
$development_mode = "<SOME_MODE>";
Init::initRequestProcessing($development_mode);The Init class, inside init/ folder, is made of static methods and attributes. Its purpose is to have a better maintainability and a clearer breakdown of the steps for starting the processing of a bot's request. So it is not a class that respects the fundamental principles of OOP design, but it is only a container of static methods and attributes.
Indeed, the content of the initRequestProcessing($development_mode) has the following method calls:
-
initializeConfiguration($development_mode): initialize the configuration, better explained in Configuration page -
initializeDatabase(): initializes the database through the configuration information -
initializeBotSdk(): initializes the Telegram Bot SDK object instance to read and send the bot's requests (LINK) -
initializeUser(): initializes the User class, useful to manage the request state (LINK -
checkBotAuthorization(): checks the bot authorization rules -
checkUserAuthorization(): checks the user authorization rules -
handleRestartCommand(): handles the restart command procedure, to force the reset of the bot state -
handleCommand(): handles every request sent to the bot, managing the state