hiradsajde / sobot
Requires
- guzzlehttp/guzzle: ^7.3
- vlucas/phpdotenv: ^5.3
This package is auto-updated.
Last update: 2025-06-20 02:14:42 UTC
README
This library have very short document. read telegram methods for bot api first
Installtion
composer require hiradsajde/sobot
git clone https://github.com/hiradsajde/sobot
composer install # if need use composer
clone method usage need autoload file for include sobot\telegram\bot
Hello World Project
<?php
require 'vendor/autoload.php'; // autoload file
$bot = new sobot\telegram\bot('telegram token');
$bot->setWebhook('url');
if($bot->isUpdate()){
$bot->getUpdate();
$bot->sendMessage('hello world');
}
Library Syntax
$bot->method(main_argument , [
'any property' => 'value'
]);
for example we can use all of there for sendMessage
$bot->sendMessage('hello world');
$bot->sendMessage([
'text' => 'hello world',
]);
$bot->sendMessage('hello world' , [
'parse_mode' => 'html',
]);
What Main Argument?
you can optionally use main argument in first parameter. for example sendMessage main argument is text.
$bot->sendMessage('hello');
$bot->sendMessage([
'text' => 'hello'
]);
you can see more methods main argument in next title
Main Arguments list
Method | Argument |
---|---|
setWebhook | url |
sendMessage | text |
editMessageText | text |
copyMessage | chat_id |
sendPhoto | photo |
more main arguments in this link
Default parameters
that's very nice option in this library is default parameters. for example we need to sendMessage sender in code. we do not have to repeat chat_id in code. we can jut use default property. for example $bot->default = [
'sendMessage' => [
'text' => 'blablabla',
],
];
$bot->sendMessage();
you can use this structure for set default properties
$bot->default = [
'method1' => [
'x' => 'y',
],
'method2' => [
'x' => 'y',
],
...
];
and we recive blablabla with out errors :) but why we aren't said default chat_id is $bot->chat_id, and message was sent? we have lot of default parameters sobot merge getDefault method to your default property and gave you truest code with very less coding
Sobot Default Property
see one example of usage properties echo $bot->chat_id;
you can see sobot properties for manage telegram json request here
Manage Keyboards
if you need to manage your keyboards with sobot... we have 2 methods for this.
$bot->keyboard([
[['text' => 'blablabla']],
]);
$bot->inline_keyboard([
[['text' => 'blablabla' , 'callback_data' => 'value]],
]);
open source project for learn sobot :