Commit 84c59ba5 authored by Francesco Iannuzzelli's avatar Francesco Iannuzzelli

Composer update

parent 6ea05abe
......@@ -2,7 +2,8 @@
"name": "peacelink/phpeace",
"require": {
"johngrogg/ics-parser": "^2.1",
"kigkonsult/icalcreator": "^2.27"
"kigkonsult/icalcreator": "^2.27",
"formapro/telegram-bot": "^0.1.14"
},
"authors": [
{
......
This diff is collapsed.
../nesbot/carbon/bin/carbon
\ No newline at end of file
......@@ -6,6 +6,11 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'd49e707fe29161c8c9e1db2a316cc7a1' => $vendorDir . '/formapro/values/src/functions_include.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'47b18101462cdeb25f661813113e3182' => $vendorDir . '/kigkonsult/icalcreator/autoload.php',
);
......@@ -7,8 +7,14 @@ $baseDir = dirname($vendorDir);
return array(
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Contracts\\' => array($vendorDir . '/symfony/contracts'),
'Symfony\\Contracts\\Translation\\' => array($vendorDir . '/symfony/translation-contracts'),
'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
'Kigkonsult\\Icalcreator\\' => array($vendorDir . '/kigkonsult/icalcreator/src', $vendorDir . '/kigkonsult/icalcreator/src/Util', $vendorDir . '/kigkonsult/icalcreator/src/Traits'),
'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
'Formapro\\Values\\' => array($vendorDir . '/formapro/values/src'),
'Formapro\\TelegramBot\\' => array($vendorDir . '/formapro/telegram-bot/src'),
'Carbon\\' => array($vendorDir . '/nesbot/carbon/src/Carbon'),
);
......@@ -7,7 +7,12 @@ namespace Composer\Autoload;
class ComposerStaticInita7e7c4caaa90f2a3850b351ca3514880
{
public static $files = array (
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
'd49e707fe29161c8c9e1db2a316cc7a1' => __DIR__ . '/..' . '/formapro/values/src/functions_include.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'47b18101462cdeb25f661813113e3182' => __DIR__ . '/..' . '/kigkonsult/icalcreator/autoload.php',
);
......@@ -15,13 +20,28 @@ class ComposerStaticInita7e7c4caaa90f2a3850b351ca3514880
'S' =>
array (
'Symfony\\Polyfill\\Mbstring\\' => 26,
'Symfony\\Contracts\\' => 18,
'Symfony\\Contracts\\Translation\\' => 30,
'Symfony\\Component\\Translation\\' => 30,
),
'P' =>
array (
'Psr\\Http\\Message\\' => 17,
),
'K' =>
array (
'Kigkonsult\\Icalcreator\\' => 23,
),
'G' =>
array (
'GuzzleHttp\\Psr7\\' => 16,
'GuzzleHttp\\Promise\\' => 19,
'GuzzleHttp\\' => 11,
),
'F' =>
array (
'Formapro\\Values\\' => 16,
'Formapro\\TelegramBot\\' => 21,
),
'C' =>
array (
'Carbon\\' => 7,
......@@ -33,20 +53,44 @@ class ComposerStaticInita7e7c4caaa90f2a3850b351ca3514880
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
),
'Symfony\\Contracts\\' =>
'Symfony\\Contracts\\Translation\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/contracts',
0 => __DIR__ . '/..' . '/symfony/translation-contracts',
),
'Symfony\\Component\\Translation\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/translation',
),
'Psr\\Http\\Message\\' =>
array (
0 => __DIR__ . '/..' . '/psr/http-message/src',
),
'Kigkonsult\\Icalcreator\\' =>
array (
0 => __DIR__ . '/..' . '/kigkonsult/icalcreator/src',
1 => __DIR__ . '/..' . '/kigkonsult/icalcreator/src/Util',
2 => __DIR__ . '/..' . '/kigkonsult/icalcreator/src/Traits',
),
'GuzzleHttp\\Psr7\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
),
'GuzzleHttp\\Promise\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/promises/src',
),
'GuzzleHttp\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
),
'Formapro\\Values\\' =>
array (
0 => __DIR__ . '/..' . '/formapro/values/src',
),
'Formapro\\TelegramBot\\' =>
array (
0 => __DIR__ . '/..' . '/formapro/telegram-bot/src',
),
'Carbon\\' =>
array (
0 => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon',
......
This diff is collapsed.
Copyright (c) 2018 Fabien Potencier
Copyright (c) 2019 FormaPro
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
# PHP Telegram Bot
Telegram bot as it should be.
## Examples
### SetWebhook
```php
<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\SetWebhook;
use function GuzzleHttp\Psr7\str;
$bot = new Bot('telegramToken');
$setWebhook = new SetWebhook('https://your.app/telegram-updates-hook');
// uncomment if use use self-signed certificate
// $setWebhook->setCertificate(file_get_contents('/path/to/self-signed-certifcate.pem'));
$response = $bot->setWebhook($setWebhook);
echo str($response);
```
### GetWebhookInfo
```php
<?php
use Formapro\TelegramBot\Bot;
use function GuzzleHttp\Psr7\str;
$bot = new Bot('telegramToken');
$response = $bot->getWebhookInfo();
echo str($response);
```
### SendMessage
```php
<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
use Formapro\TelegramBot\SendMessage;
$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody, true);
$update = Update::create($data);
$bot = new Bot('telegramToken');
$bot->sendMessage(new SendMessage(
$update->getMessage()->getChat()->getId(),
'Hi there! What can I do?'
));
```
### SendPhoto
**Note:** if you want to send gif with many pictures inside -
use `sendDocument`
```php
<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
use Formapro\TelegramBot\SendMessage;
$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody, true);
$update = Update::create($data);
// You can pass URI of image or a path to file
$picture = '/path/to/picture'; // OR https://some-server.com/some.jpg
$sendPhoto = new SendPhoto(
$update->getMessage()->getChat()->getId(),
file_get_contents($picture) // or just $picture if it's url
);
// also you can set `caption` to image
$sendPhoto->setCaption('Some caption under the picture');
$bot = new Bot('telegramToken');
$bot->sendPhoto($sendPhoto);
```
### SendDocument
**Note:** _sending by URL will currently only work for
gif, pdf and zip files._ (from documentation)
```php
<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
use Formapro\TelegramBot\SendDocument;
use Formapro\TelegramBot\FileUrl;
use Formapro\TelegramBot\FileId;
use Formapro\TelegramBot\InputFile;
$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody, true);
$update = Update::create($data);
// You can pass URI of image or a path to file
//$document = new FileUrl('https://some-server.com/some.pdf');
// You can pass an ID of already stored file on Telegram side.
//$document = new FileId('123');
// You can pass local file.
$document = new InputFile('test.txt', 'Hi there!');
$sendDocument = SendDocument::withInputFile(
$update->getMessage()->getChat()->getId(),
$document
);
// also you can set `caption` to image
$sendDocument->setCaption('Some caption under the document');
$bot = new Bot('telegramToken');
$bot->sendDocument($sendDocument);
```
### SendInvoice
```php
<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
use Formapro\TelegramBot\SendInvoice;
$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody, true);
$update = Update::create($data);
$payload = []; // any params which you need to proccess in the transaction
$providerToken = 'something:like:this'; // Token have to be taken from botFather
$sendInvoice = new SendInvoice(
$update->getMessage()->getChat()->getId(),
'Your title',
'Your description of invoice',
json_encode($payload),
$providerToken,
'12314czasdq', // unique id
'UAH',
[new LabeledPrice('PriceLabel_1', 3001)] // amount; here 30.01 UAH
);
$bot = new Bot('telegramToken');
$bot->sendInvoice($sendInvoice);
```
### ReplyKeyboardMarkup
```php
<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
use Formapro\TelegramBot\SendMessage;
use Formapro\TelegramBot\KeyboardButton;
use Formapro\TelegramBot\ReplyKeyboardMarkup;
$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody, true);
$update = Update::create($data);
$fooButton = new KeyboardButton('foo');
$barButton = new KeyboardButton('bar');
$bazButton = new KeyboardButton('bar');
$keyboard = new ReplyKeyboardMarkup([[$fooButton], [$barButton, $bazButton]]);
$sendMessage = new SendMessage($update->getMessage()->getChat()->getId(), 'Choose an option.');
$sendMessage->setReplyMarkup($keyboard);
$bot = new Bot('telegramToken');
$bot->sendMessage($sendMessage);
```
Request Contacts:
```php
<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
use Formapro\TelegramBot\SendMessage;
use Formapro\TelegramBot\KeyboardButton;
use Formapro\TelegramBot\ReplyKeyboardMarkup;
$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody, true);
$update = Update::create($data);
$button = new KeyboardButton('Share my contacts');
$button->setRequestContact(true);
$keyboard = new ReplyKeyboardMarkup([[$button]]);
$keyboard->setOneTimeKeyboard(true);
$sendMessage = new SendMessage($update->getMessage()->getChat()->getId(), 'Please, share your contact info with us.');
$sendMessage->setReplyMarkup($keyboard);
$bot = new Bot('telegramToken');
$bot->sendMessage($sendMessage);
```
### InlineKeyboardButton
Url:
```php
<?php
use Formapro\TelegramBot\InlineKeyboardButton;
use Formapro\TelegramBot\InlineKeyboardMarkup;
use Formapro\TelegramBot\SendMessage;
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody, true);
$update = Update::create($data);
$button = InlineKeyboardButton::withUrl('inline button', 'https://your.app/link');
$keyboard = new InlineKeyboardMarkup([[$button]]);
$sendMessage = new SendMessage($update->getMessage()->getChat()->getId(), 'Click on inline button.');
$sendMessage->setReplyMarkup($keyboard);
$bot = new Bot('telegramToken');
$bot->sendMessage($sendMessage);
```
CallbackQuery:
```php
<?php
use Formapro\TelegramBot\InlineKeyboardButton;
use Formapro\TelegramBot\InlineKeyboardMarkup;
use Formapro\TelegramBot\SendMessage;
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody, true);
$update = Update::create($data);
$button = InlineKeyboardButton::withCallbackData('inline button', 'some_data');
$keyboard = new InlineKeyboardMarkup([[$button]]);
$sendMessage = new SendMessage($update->getMessage()->getChat()->getId(), 'Click on inline button.');
$sendMessage->setReplyMarkup($keyboard);
$bot = new Bot('telegramToken');
$bot->sendMessage($sendMessage);
```
## AnswerCallbackQuery
```php
<?php
use Formapro\TelegramBot\AnswerCallbackQuery;
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody, true);
$update = Update::create($data);
if ($callbackQuery = $update->getCallbackQuery()) {
$bot = new Bot('telegramToken');
$bot->answerCallbackQuery(new AnswerCallbackQuery($callbackQuery->getId()));
}
```
## Developed by Forma-Pro
Forma-Pro is a full stack development company which interests also spread to open source development.
Being a team of strong professionals we have an aim an ability to help community by developing cutting edge solutions in the areas of e-commerce, docker & microservice oriented architecture where we have accumulated a huge many-years experience.
Our main specialization is Symfony framework based solution, but we are always looking to the technologies that allow us to do our job the best way. We are committed to creating solutions that revolutionize the way how things are developed in aspects of architecture & scalability.
If you have any questions and inquires about our open source development, this product particularly or any other matter feel free to contact at opensource@forma-pro.com
## License
It is released under the [MIT License](LICENSE).
{
"name": "formapro/telegram-bot",
"type": "library",
"description": "PHP Telegram Bot",
"keywords": ["telegram", "bot", "client"],
"license": "MIT",
"require": {
"php": "^7.1.3",
"formapro/values": "^0.5.1",
"guzzlehttp/guzzle": "^6.3"
},
"autoload": {