Download the PHP package natilosir/telegram-bot-sdk without Composer
On this page you can find all versions of the php package natilosir/telegram-bot-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package telegram-bot-sdk
Bot-SDK
A professional SDK BOT Telegram for PHP
Requirements
- PHP >= 5.4
- Composer
Installation
You can install this SDK package via Composer:
ORM
Error log
- Advanced error management and storing logs in a separate file
log.txt
for every request to the server.Editor.php
Overview
Editor.php
is an online code editor that allows users to edit files in a manner similar to Visual Studio Code (VSCode). It provides a user-friendly interface for managing and editing code files directly from your web browser.
Opening Files
By default, the editor opens the file route.php
. If you want to open other files, you can do so by appending the file path to the URL, like this:
Handling Unsaved Files
If you encounter an "Error opening file" message when trying to open a file that has not been saved previously, please press Ctrl + S
. This action will create a new file and automatically save it.
Saving Files
To save your changes, you can click the purple "Save" button located in the top right corner of the editor (for mobile users). Alternatively, you can use the keyboard shortcut Ctrl + S
to save the file quickly.
Features
- User-friendly interface
android
windows
- Supports multiple file editing
php
js
html
css
etc... - Keyboard shortcuts for efficiency
Ctrl + S
Route::Class
Please provide the code you would like me to review.
Now we will review all sections of the code. To use this class, make sure to include use natilosir\bot\Route;
before calling the Route class.
add Method Overview
This method accepts two parameters: patterns
and action
.
-
Patterns (Input 1):
- You can specify the patterns as either an array or a string. This defines the command or phrase that, when triggered by the user, will determine which file to open.
- For example, if the user types and sends the command
/start
, you would specify this command in the patterns parameter.
-
Action (Input 2):
- The second input is the path to the file located within the
controller
directory. - For instance, if there is a file named
start.php
in thecontroller
folder, you should provide the second input simply asstart
. The system will automatically understand that it needs to open the file located atcontroller/start.php
.
- The second input is the path to the file located within the
- Accessing Files from Other Directories:
- If you want to open a file from a different folder, you can use the
.
notation. - For example, if you want to open the file
controller/user/send.php
, you would specify the second input asuser/send
.
- If you want to open a file from a different folder, you can use the
Example Usage add methods
Default Method Overview
Using the def
method, you can specify a default file to be opened. This is particularly useful when a user sends a command that does not match any of the patterns defined in the add
method.
How It Works
- If the user sends a command that does not match any of the patterns specified in the
add
method, thedef
method allows you to display a default message or response. - This can help guide users or provide them with additional options when they input an unrecognized command.
Example Usage
Handle Method Overview
The handle
method is designed to process user input. It allows the system to receive a specific string or command sent by the user.
How It Works
- You can use the
Route::handle($text);
method to capture the$text
input from the user. - This method is essential for handling commands or messages that users send to your bot.
Example Usage
Bot::Class
HTTP request
deleteMessage
Method
The deleteMessage
method allows you to delete a message from a chat.
Parameters
$chatID
(int): The unique identifier for the target chat.$message_id
(int): The unique identifier for the message to be deleted.
Example
forwardMessage
Method
The forwardMessage
method allows you to forward a message from one chat to another.
Parameters
$chatID
(int): The ID of the chat where the message will be forwarded.$from_chat_id
(int): The ID of the chat from which the message is being forwarded.$message_id
(int): The ID of the message to be forwarded.
Example Usage
sendMessage
Method
The sendMessage
method sends a text message to a specified chat.
Parameters
$chatID
(int): The unique identifier for the target chat.$text
(string): The text of the message to be sent.$reply_to_message_id
(int, optional): If the message is a reply, ID of the original message.$reply_markup
(array, optional): Additional interface options, such as inline keyboard.
Example
copyMessage
Method
The copyMessage
method allows you to copy a message from one chat to another in a Telegram bot.
Parameters
$chatID
(int): The ID of the chat where the message will be sent.$second_chat_id
(int): The ID of the chat from which the message will be copied.$message_id
(int): The ID of the message that needs to be copied.$reply_markup
(array|null, optional): Optional. Additional reply markup for the copied message.
Example
inline
Method
The inline
method allows you to create inline keyboard buttons for your bot.
Parameters
- $text (string): The text displayed on the button.
- $callback_data (string|null): The data sent back to the bot when the button is pressed. This can be used to identify the button action.
- $url (string|null): (Optional) A URL to be opened when the button is pressed. If this is provided,
callback_data
will be ignored.
Example
Here is an example of how to use the inline
method to create an inline keyboard with a button:
keyboard
Method
The keyboard
method allows you to create a custom keyboard layout for your bot's messages.
Parameters
- $chatID (int): The unique identifier for the target chat where the keyboard will be sent.
- $text (string): The text message to accompany the keyboard.
- $reply_markup (array|null): (Optional) An array defining the keyboard layout. If not provided, a default keyboard will be used.
Example
editMessageReplyMarkup
Method
The editMessageReplyMarkup
method is used to edit the reply markup of a message sent by the bot.
Parameters
chat_id
: (integer|string) Unique identifier for the target chat or username of the target channel (in the format@channelusername
).message_id
: (integer) Identifier of the message to edit.reply_markup
: (array|null) A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard, or to force a reply from the user.
Example
answerCallbackQuery
Method
This method is used to send a response to a callback query received from a button press in a Telegram bot.
Parameters
$query_id
: The unique identifier for the callback query.$text
: The text message to be sent as a response.$show_alert
: (Optional) A boolean value indicating whether to show an alert instead of a notification. Default isfalse
.
Example Usage
alert
Method
The alert
method is used to send an alert to the user in response to a callback query.
Parameters
$query_id
: (string) The unique identifier for the callback query.$text
: (string) The text of the alert message to be displayed.$show_alert
: (bool, optional) Determines whether to show the alert as a modal dialog. Default isfalse
.
Example
sendChatAction
Method
The sendChatAction
method is used to send a chat action (like typing, uploading, etc.) to a specific chat.
Parameters
$chatID
(int|string): The unique identifier for the target chat or username of the target channel (in the format@channelusername
).$action
(string): The action to be sent. Possible values are:typing
upload_photo
record_video
upload_video
record_audio
upload_audio
upload_document
find_location
record_video_note
upload_video_note