Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glebsky/simple-telegram
Simple Service to work with sending messages,photos,audios via telegram bot
https://github.com/glebsky/simple-telegram
php telegram telegram-bot telegram-bot-api telegram-messages
Last synced: 27 days ago
JSON representation
Simple Service to work with sending messages,photos,audios via telegram bot
- Host: GitHub
- URL: https://github.com/glebsky/simple-telegram
- Owner: Glebsky
- Created: 2021-08-20T07:01:03.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-29T20:33:17.000Z (almost 3 years ago)
- Last Synced: 2024-04-22T00:52:29.249Z (7 months ago)
- Topics: php, telegram, telegram-bot, telegram-bot-api, telegram-messages
- Language: PHP
- Homepage:
- Size: 14.6 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
![logo](https://i.ibb.co/Vv58qTS/simple-Telegram.png "Simple Telegram")
βοΈ π πΌοΈ π§ => π€ => π
A simple way to send messages to the user through the telegram bot.---
[
Telegram Bot Documentation |
Supported formats
]## About
This is a simple class that will allow you to easily send messages, documents, photos, audio to users. The library is specially designed to have fewer dependencies.## Installation
The library can be installed using the composer:
```bash
Ρomposer install glebsky/simple-telegram
```
Or you can take a ready-made class from the `src` folder since there are no dependencies.
## How to use
Add in use section:
```php
use Glebsky\SimpleTelegram\SimpleTelegram;
```
And add your SimpleTelegram To your code section to send messages:
```php
$botTokent = '132312455234:DSQWDQWQWEZCZXKGWETJHSOASDZXC_s';
$chat_id = '123456789';
$telegram = new SimpleTelegram($botTokent,$chat_id);$telegram->sendMessage('Test Message');
$telegram->sendDocument(__DIR__.'/demo.txt','Document Caption');
$telegram->sendPhoto(__DIR__.'/photo.jpg','Photo Caption');
$telegram->sendAudio(__DIR__.'/audio.mp3','Audio Caption');
```
>Please note that the path to the file must be specified absolute.You can change the addressee or get the current addressee (chat_id)
```php
$telegram->setRecipient('123456789');
$telegram->getRecipient(); // 123456789
```
Also, you can choose not to specify the receiver when initializing the class; this can be done later before sending.
```php
$botTokent = '132312455234:DSQWDQWQWEZCZXKGWETJHSOASDZXC_s';
$telegram = new SimpleTelegram($botTokent);$chat_id = '123456789';
$telegram->setRecipient($chat_id);$telegram->sendMessage('Test Message');
```
Or you can combine queries
```php
$telegram = new SimpleTelegram($botTokent);$chat_id = '123456789';
$telegram->setRecipient($chat_id)->sendPhoto(__DIR__.'/photo.jpg','Photo Caption');
```Submission methods return `true` on successful submission and `false` on failure
```php
$telegram->sendMessage('Test Message'); // true or false
$telegram->sendDocument(__DIR__.'/demo.txt','Document Caption'); // true or false
$telegram->sendPhoto(__DIR__.'/photo.jpg','Photo Caption'); // true or false
$telegram->sendAudio(__DIR__.'/audio.mp3','Audio Caption'); // true or false
```