https://github.com/muaath5/simplebotapi
Simple & Easy Telegram Bot API in PHP
https://github.com/muaath5/simplebotapi
bot bot-api php php8 telegram telegram-api telegram-bot telegram-bot-api
Last synced: 5 months ago
JSON representation
Simple & Easy Telegram Bot API in PHP
- Host: GitHub
- URL: https://github.com/muaath5/simplebotapi
- Owner: Muaath5
- License: gpl-3.0
- Created: 2021-07-24T18:44:26.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-19T22:40:48.000Z (over 1 year ago)
- Last Synced: 2025-03-26T21:23:12.592Z (11 months ago)
- Topics: bot, bot-api, php, php8, telegram, telegram-api, telegram-bot, telegram-bot-api
- Language: PHP
- Homepage: http://simplebotapi.muaath.dev/
- Size: 104 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# Simple Bot API
[](LICENCE)
[](https://core.telegram.org/bots/api)
[](https://github.com/Muaath5/SimpleBotAPI/actions/workflows/php.yml)
This is a simple Telegram Bot API library in PHP.
This library should support all Bot API methods in any version update.
I created this library to make creating bots more simpliler, No need to bunch of classes And objects after today!
## Features
- Always supports all Bot API methods
- Auto handling for flood & chat ID migrating errors
- Uses `stdClass` for updates
- Uses OOP
- Optional Settings for each bot can be saved in JSON
- Based on cURL for speed
- Downloadable via composer
- Tested via GitHub Actions
- Has examples of working bots
- Telegram Errors as PHP Exceptions
- Up to date
- Documented
## Installation
[Installation Guide](https://muaath5.github.io/SimpleBotAPI/Installation)
## Simple Usage
### Creating bot
```php
use SimpleBotAPI/TelegramBot;
use SimpleBotAPI/BotSettings;
$Bot = new TelegramBot('bot_token');
```
More documentation [here](https://muaath5.github.io/SimpleBotAPI/CreatingBot)
### Using method
It should be in this format:
```
$Result = $Bot->{methodName}([
'{paramName}' => {value1},
'{paramName2}' => {value2}
]);
```
Like this:
```php
$Bot->SendMessage([
'chat_id' => '@MuaathBots',
'text' => 'This post was sent by the bot..'
]);
$my_channel_info = $Bot->getChat([
'chat_id' => '@MuaathBots',
]);
echo "Your channel (@{$my_channel_info->username}) ID: {$my_channel_info->id}";
```
**Note:** There's NO PROBLEM if `methodName` was in upper or lower case.
## Contibuting
You can contribute by:
- Reporting a bug.
- Suggesting a feature.
- Improving code style.
- Completing the TODO List.
- Adding more examples to `examples/`.
- Documenting undocumented topics in `docs/`.
- Updating the library to the next version of Bot API (if needed).
- Adding more tests in `test/` folder.
## Contact me
[](https://t.me/Muaath_5)
[](mailto:muaath1428@hotmail.com)
## Examples
Currently, There're three examples in `examples/` folder:
- Echo Bot, Which sends same as you sent
- Weclome Bot, Which sends Welcome & ID of user who joins the group
- Contact Me Bot, Which is a Bot be same as you, You'll receive messages & Reply
- FAQ Bot, Which has one message & buttons to swap between questions, And you can see answers.
You can see a full example [here](https://muaath5.github.io/SimpleBotAPI/FullExample)
**All of these examples doesn't need any databases or files to storage, Only Settings file.**
## TODO List
- [x] API via HTTP response in webhooks method
- [x] Using namespace for exceptions
- [x] Documenting sending message with reply markup
- [x] Add webhook authorization
- [x] Auto-store for bot users
- [x] Add JSON Storage can be used by bot
- [x] Method that posts to all bot users
- [X] Add logging
- [ ] Add DB Storage can be used by bot
- [ ] Document missed things
## License
[](LICENCE)
GPL-3.0, In LICENCE file.