diff --git a/.gitignore b/.gitignore
index 30e3b31..e20bdad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,4 +15,5 @@
/gradlew.bat
/package-lock.php.yml
/out/**
-/dn-sources/**
\ No newline at end of file
+/dn-sources/**
+.phpintel/**
diff --git a/README.MD b/README.MD
index 8ed9ec2..fcc5adc 100644
--- a/README.MD
+++ b/README.MD
@@ -41,6 +41,73 @@ $listener->addListener(function($update){
});
$listener->start();
```
+### Использование клавиатуры
+#### Клавиатура под полем ввода (ReplyKeyboard)
+
+```php
+$api = new TelegramBotApi($bot_token);
+
+$keyboard = TMarkup::replyKeyboard()
+ ->button('Button 1')->button('Button 2')
+ ->row()
+ ->button('Row 2')->button('Hello world')->button('test 123')
+ ->row()
+ ->button('Button in row 3');
+
+$api->sendMessage()
+ ->chat_id(123456)
+ ->text('Hello world')
+ ->reply_markup($keyboard)
+ ->query();
+```
+
+#### Удаление клавиатуры под полем ввода (ReplyKeyboard)
+```php
+$api = new TelegramBotApi($bot_token);
+
+$hideKeyboard = TMarkup::removeKeyboard();
+
+$api->sendMessage()
+ ->chat_id(123456)
+ ->text('Hello world')
+ ->reply_markup($hideKeyboard)
+ ->query();
+```
+
+#### Клавиатура под сообщением (InlineKeyboard)
+
+```php
+$api = new TelegramBotApi($bot_token);
+
+// Обязательно вторым аргументом у button указывать данные для callback_data или url-ссылку
+$keyboard = TMarkup::inlineKeyboard()
+ ->button('Button with callback', 'press_1')->button('Button 2', 'press_2')
+ ->row()
+ ->button('Link to google', 'https://google.com')->button('Link to git', 'http://github.com')
+ ->row()
+ ->button('1', 'btn_1')->button('2', 'btn_2')->button('3', 'btn_3')->button('4', 'btn_4')->button('5', 'btn_5')->button('6', 'btn_6')->button('7', 'btn_7')->button('8', 'btn_8');
+
+$api->sendMessage()
+ ->chat_id(123456)
+ ->text('Hello world')
+ ->reply_markup($keyboard)
+ ->query();
+```
+
+#### Ответ на сообщение (ForceReply)
+
+```php
+$api = new TelegramBotApi($bot_token);
+
+$reply = TMarkup::forceReply();
+
+$api->sendMessage()
+ ->chat_id(123456)
+ ->text('Hello world')
+ ->reply_markup($reply)
+ ->query();
+```
+
## Расширение для DevelNext
[Скачать](https://github.com/broelik/jphp-telegram-bot-api/releases/latest)
diff --git a/api-docs/README.md b/api-docs/README.md
index ab70d44..c7c8ba1 100644
--- a/api-docs/README.md
+++ b/api-docs/README.md
@@ -1,10 +1,10 @@
## telegram-bot-api
-> version 1.0.0, created by JPPM.
+> version 1.1.0, created by JPPM.
### Install
```
-jppm add telegram-bot-api@1.0.0
+jppm add telegram-bot-api@1.1.0
```
### API
@@ -15,6 +15,14 @@ jppm add telegram-bot-api@1.0.0
- [`TelegramError`](classes/telegram/exception/TelegramError.md)
- [`TelegramException`](classes/telegram/exception/TelegramException.md)
+#### `telegram\object\markup`
+
+- [`AbstractMarkup`](classes/telegram/object/markup/AbstractMarkup.md)
+- [`TForceReply`](classes/telegram/object/markup/TForceReply.md)- _Shows reply interface to the user, as if they manually selected the bot‘s message and tapped 'Reply'_
+- [`TInlineKeyboard`](classes/telegram/object/markup/TInlineKeyboard.md)- _This object represents an inline keyboard that appears right next to the message it belongs to._
+- [`TReplyKeyboard`](classes/telegram/object/markup/TReplyKeyboard.md)- _This object represents a custom keyboard with reply options_
+- [`TReplyKeyboardRemove`](classes/telegram/object/markup/TReplyKeyboardRemove.md)- _Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button_
+
#### `telegram\object`
- [`TAudio`](classes/telegram/object/TAudio.md)
@@ -23,6 +31,7 @@ jppm add telegram-bot-api@1.0.0
- [`TDocument`](classes/telegram/object/TDocument.md)
- [`TFile`](classes/telegram/object/TFile.md)
- [`TLocation`](classes/telegram/object/TLocation.md)
+- [`TMarkup`](classes/telegram/object/TMarkup.md)
- [`TMessage`](classes/telegram/object/TMessage.md)
- [`TMessageEntity`](classes/telegram/object/TMessageEntity.md)
- [`TPhotoSize`](classes/telegram/object/TPhotoSize.md)
@@ -36,6 +45,7 @@ jppm add telegram-bot-api@1.0.0
#### `telegram\query`
+- [`TAnswerCallbackQuery`](classes/telegram/query/TAnswerCallbackQuery.md)- _Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned._
- [`TBaseQuery`](classes/telegram/query/TBaseQuery.md)
- [`TEditMessageTextQuery`](classes/telegram/query/TEditMessageTextQuery.md)
- [`TForwardMessageQuery`](classes/telegram/query/TForwardMessageQuery.md)
diff --git a/api-docs/classes/telegram/TelegramBotApi.md b/api-docs/classes/telegram/TelegramBotApi.md
index c7a4705..10a9a95 100644
--- a/api-docs/classes/telegram/TelegramBotApi.md
+++ b/api-docs/classes/telegram/TelegramBotApi.md
@@ -35,6 +35,7 @@
- `->`[`kickChatMember()`](#method-kickchatmember)
- `->`[`unbanChatMember()`](#method-unbanchatmember)
- `->`[`getUpdates()`](#method-getupdates)
+- `->`[`answerCallbackQuery()`](#method-answercallbackquery)
- `->`[`setProxy()`](#method-setproxy)
- `->`[`getProxy()`](#method-getproxy)
- `->`[`setToken()`](#method-settoken)
@@ -217,6 +218,15 @@ getUpdates(): TGetUpdatesQuery
---
+
+
+### answerCallbackQuery()
+```php
+answerCallbackQuery(): TAnswerCallbackQuery
+```
+
+---
+
### setProxy()
diff --git a/api-docs/classes/telegram/object/TMarkup.md b/api-docs/classes/telegram/object/TMarkup.md
new file mode 100644
index 0000000..c3c9e93
--- /dev/null
+++ b/api-docs/classes/telegram/object/TMarkup.md
@@ -0,0 +1,50 @@
+# TMarkup
+
+- **class** `TMarkup` (`telegram\object\TMarkup`)
+- **source** `telegram/object/TMarkup.php`
+
+---
+
+#### Static Methods
+
+- `TMarkup ::`[`replyKeyboard()`](#method-replykeyboard)
+- `TMarkup ::`[`inlineKeyboard()`](#method-inlinekeyboard)
+- `TMarkup ::`[`forceReply()`](#method-forcereply)
+- `TMarkup ::`[`removeKeyboard()`](#method-removekeyboard)
+
+---
+# Static Methods
+
+
+
+### replyKeyboard()
+```php
+TMarkup::replyKeyboard(): TReplyKeyboard
+```
+
+---
+
+
+
+### inlineKeyboard()
+```php
+TMarkup::inlineKeyboard(): TInlineKeyboard
+```
+
+---
+
+
+
+### forceReply()
+```php
+TMarkup::forceReply(): TForceReply
+```
+
+---
+
+
+
+### removeKeyboard()
+```php
+TMarkup::removeKeyboard(): TReplyKeyboardRemove
+```
\ No newline at end of file
diff --git a/api-docs/classes/telegram/object/markup/AbstractMarkup.md b/api-docs/classes/telegram/object/markup/AbstractMarkup.md
new file mode 100644
index 0000000..511a75f
--- /dev/null
+++ b/api-docs/classes/telegram/object/markup/AbstractMarkup.md
@@ -0,0 +1,30 @@
+# AbstractMarkup
+
+- **class** `AbstractMarkup` (`telegram\object\markup\AbstractMarkup`)
+- **source** `telegram/object/markup/AbstractMarkup.php`
+
+**Child Classes**
+
+> [TForceReply](classes/telegram/object/markup/TForceReply.md), [TReplyKeyboard](classes/telegram/object/markup/TReplyKeyboard.md), [TReplyKeyboardRemove](classes/telegram/object/markup/TReplyKeyboardRemove.md)
+
+---
+
+#### Properties
+
+- `->`[`markup`](#prop-markup) : `array`
+
+---
+
+#### Methods
+
+- `->`[`getMarkup()`](#method-getmarkup)
+
+---
+# Methods
+
+
+
+### getMarkup()
+```php
+getMarkup(): array
+```
\ No newline at end of file
diff --git a/api-docs/classes/telegram/object/markup/TForceReply.md b/api-docs/classes/telegram/object/markup/TForceReply.md
new file mode 100644
index 0000000..0445e9e
--- /dev/null
+++ b/api-docs/classes/telegram/object/markup/TForceReply.md
@@ -0,0 +1,36 @@
+# TForceReply
+
+- **class** `TForceReply` (`telegram\object\markup\TForceReply`) **extends** [`AbstractMarkup`](classes/telegram/object/markup/AbstractMarkup.md)
+- **source** `telegram/object/markup/TForceReply.php`
+
+**Description**
+
+Shows reply interface to the user, as if they manually selected the bot‘s message and tapped 'Reply'
+
+---
+
+#### Methods
+
+- `->`[`__construct()`](#method-__construct)
+- `->`[`setSelective()`](#method-setselective) - _Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message._
+- See also in the parent class [AbstractMarkup](classes/telegram/object/markup/AbstractMarkup.md)
+
+---
+# Methods
+
+
+
+### __construct()
+```php
+__construct(): void
+```
+
+---
+
+
+
+### setSelective()
+```php
+setSelective(bool $value): void
+```
+Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
\ No newline at end of file
diff --git a/api-docs/classes/telegram/object/markup/TInlineKeyboard.md b/api-docs/classes/telegram/object/markup/TInlineKeyboard.md
new file mode 100644
index 0000000..4d675d5
--- /dev/null
+++ b/api-docs/classes/telegram/object/markup/TInlineKeyboard.md
@@ -0,0 +1,37 @@
+# TInlineKeyboard
+
+- **class** `TInlineKeyboard` (`telegram\object\markup\TInlineKeyboard`) **extends** [`TReplyKeyboard`](classes/telegram/object/markup/TReplyKeyboard.md)
+- **source** `telegram/object/markup/TInlineKeyboard.php`
+
+**Description**
+
+This object represents an inline keyboard that appears right next to the message it belongs to.
+
+
+---
+
+#### Methods
+
+- `->`[`button()`](#method-button) - _Добавить кнопку_
+- `->`[`getMarkup()`](#method-getmarkup)
+- See also in the parent class [TReplyKeyboard](classes/telegram/object/markup/TReplyKeyboard.md)
+
+---
+# Methods
+
+
+
+### button()
+```php
+button(string $text): TInlineKeyboard
+```
+Добавить кнопку
+
+---
+
+
+
+### getMarkup()
+```php
+getMarkup(): array
+```
\ No newline at end of file
diff --git a/api-docs/classes/telegram/object/markup/TReplyKeyboard.md b/api-docs/classes/telegram/object/markup/TReplyKeyboard.md
new file mode 100644
index 0000000..edbeaa6
--- /dev/null
+++ b/api-docs/classes/telegram/object/markup/TReplyKeyboard.md
@@ -0,0 +1,105 @@
+# TReplyKeyboard
+
+- **class** `TReplyKeyboard` (`telegram\object\markup\TReplyKeyboard`) **extends** [`AbstractMarkup`](classes/telegram/object/markup/AbstractMarkup.md)
+- **source** `telegram/object/markup/TReplyKeyboard.php`
+
+**Child Classes**
+
+> [TInlineKeyboard](classes/telegram/object/markup/TInlineKeyboard.md)
+
+**Description**
+
+This object represents a custom keyboard with reply options
+
+
+---
+
+#### Properties
+
+- `->`[`params`](#prop-params) : `array`
+- `->`[`buttons`](#prop-buttons) : `array` - _Кнопки_
+- `->`[`row`](#prop-row) : `int` - _Указатель текущей строки в кнопках_
+- *See also in the parent class* [AbstractMarkup](classes/telegram/object/markup/AbstractMarkup.md).
+
+---
+
+#### Methods
+
+- `->`[`__construct()`](#method-__construct)
+- `->`[`row()`](#method-row) - _Добавить новую строку в панель кнопок_
+- `->`[`button()`](#method-button) - _Добавить кнопку_
+- `->`[`setResize()`](#method-setresize) - _Указывает клиенту подогнать высоту клавиатуры под количество кнопок_
+- `->`[`setOneTime()`](#method-setonetime) - _Указывает клиенту скрыть клавиатуру после использования (после нажатия на кнопку)._
+- `->`[`setSelective()`](#method-setselective)
+- `->`[`getMarkup()`](#method-getmarkup)
+- See also in the parent class [AbstractMarkup](classes/telegram/object/markup/AbstractMarkup.md)
+
+---
+# Methods
+
+
+
+### __construct()
+```php
+__construct(array $params): void
+```
+
+---
+
+
+
+### row()
+```php
+row(): TReplyKeyboard
+```
+Добавить новую строку в панель кнопок
+
+---
+
+
+
+### button()
+```php
+button(string $text): TReplyKeyboard
+```
+Добавить кнопку
+
+---
+
+
+
+### setResize()
+```php
+setResize(bool $value): TReplyKeyboard
+```
+Указывает клиенту подогнать высоту клавиатуры под количество кнопок
+(сделать её меньше, если кнопок мало и наоборот)
+
+---
+
+
+
+### setOneTime()
+```php
+setOneTime(bool $value): TReplyKeyboard
+```
+Указывает клиенту скрыть клавиатуру после использования (после нажатия на кнопку).
+Её по-прежнему можно будет открыть через иконку в поле ввода сообщения.
+
+---
+
+
+
+### setSelective()
+```php
+setSelective(bool $value): TReplyKeyboard
+```
+
+---
+
+
+
+### getMarkup()
+```php
+getMarkup(): array
+```
\ No newline at end of file
diff --git a/api-docs/classes/telegram/object/markup/TReplyKeyboardRemove.md b/api-docs/classes/telegram/object/markup/TReplyKeyboardRemove.md
new file mode 100644
index 0000000..0f0e997
--- /dev/null
+++ b/api-docs/classes/telegram/object/markup/TReplyKeyboardRemove.md
@@ -0,0 +1,36 @@
+# TReplyKeyboardRemove
+
+- **class** `TReplyKeyboardRemove` (`telegram\object\markup\TReplyKeyboardRemove`) **extends** [`AbstractMarkup`](classes/telegram/object/markup/AbstractMarkup.md)
+- **source** `telegram/object/markup/TReplyKeyboardRemove.php`
+
+**Description**
+
+Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button
+
+---
+
+#### Methods
+
+- `->`[`__construct()`](#method-__construct)
+- `->`[`setSelective()`](#method-setselective) - _Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message._
+- See also in the parent class [AbstractMarkup](classes/telegram/object/markup/AbstractMarkup.md)
+
+---
+# Methods
+
+
+
+### __construct()
+```php
+__construct(): void
+```
+
+---
+
+
+
+### setSelective()
+```php
+setSelective(bool $value): void
+```
+Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
\ No newline at end of file
diff --git a/api-docs/classes/telegram/query/TAnswerCallbackQuery.md b/api-docs/classes/telegram/query/TAnswerCallbackQuery.md
new file mode 100644
index 0000000..5bdd160
--- /dev/null
+++ b/api-docs/classes/telegram/query/TAnswerCallbackQuery.md
@@ -0,0 +1,81 @@
+# TAnswerCallbackQuery
+
+- **class** `TAnswerCallbackQuery` (`telegram\query\TAnswerCallbackQuery`) **extends** [`TBaseQuery`](classes/telegram/query/TBaseQuery.md)
+- **source** `telegram/query/TAnswerCallbackQuery.php`
+
+**Description**
+
+Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
+
+
+---
+
+#### Methods
+
+- `->`[`__construct()`](#method-__construct)
+- `->`[`callback_query_id()`](#method-callback_query_id) - _Unique identifier for the query to be answered_
+- `->`[`text()`](#method-text) - _Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters_
+- `->`[`url()`](#method-url) - _URL that will be opened by the user's client._
+- `->`[`show_alert()`](#method-show_alert) - _If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false._
+- `->`[`cache_time()`](#method-cache_time) - _The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0._
+- See also in the parent class [TBaseQuery](classes/telegram/query/TBaseQuery.md)
+
+---
+# Methods
+
+
+
+### __construct()
+```php
+__construct(telegram\TelegramBotApi $api): void
+```
+
+---
+
+
+
+### callback_query_id()
+```php
+callback_query_id(string $value): TAnswerCallbackQuery
+```
+Unique identifier for the query to be answered
+
+---
+
+
+
+### text()
+```php
+text(string $value): TAnswerCallbackQuery
+```
+Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
+
+---
+
+
+
+### url()
+```php
+url(string $value): TAnswerCallbackQuery
+```
+URL that will be opened by the user's client.
+
+---
+
+
+
+### show_alert()
+```php
+show_alert(string $value): TAnswerCallbackQuery
+```
+If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
+
+---
+
+
+
+### cache_time()
+```php
+cache_time(string $value): TAnswerCallbackQuery
+```
+The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
\ No newline at end of file
diff --git a/api-docs/classes/telegram/query/TBaseQuery.md b/api-docs/classes/telegram/query/TBaseQuery.md
index 42ada27..e9b26a9 100644
--- a/api-docs/classes/telegram/query/TBaseQuery.md
+++ b/api-docs/classes/telegram/query/TBaseQuery.md
@@ -5,7 +5,7 @@
**Child Classes**
-> [TEditMessageTextQuery](classes/telegram/query/TEditMessageTextQuery.md), [TForwardMessageQuery](classes/telegram/query/TForwardMessageQuery.md), [TGetFileQuery](classes/telegram/query/TGetFileQuery.md), [TGetMeQuery](classes/telegram/query/TGetMeQuery.md), [TGetUpdatesQuery](classes/telegram/query/TGetUpdatesQuery.md), [TGetUserProfilePhotosQuery](classes/telegram/query/TGetUserProfilePhotosQuery.md), [TKickChatMemberQuery](classes/telegram/query/TKickChatMemberQuery.md), [TSendAudioQuery](classes/telegram/query/TSendAudioQuery.md), [TSendChatActionQuery](classes/telegram/query/TSendChatActionQuery.md), [TSendContactQuery](classes/telegram/query/TSendContactQuery.md), [TSendDocumentQuery](classes/telegram/query/TSendDocumentQuery.md), [TSendLocationQuery](classes/telegram/query/TSendLocationQuery.md), [TSendMessageQuery](classes/telegram/query/TSendMessageQuery.md), [TSendPhotoQuery](classes/telegram/query/TSendPhotoQuery.md), [TSendStickerQuery](classes/telegram/query/TSendStickerQuery.md), [TSendVenueQuery](classes/telegram/query/TSendVenueQuery.md), [TSendVideoQuery](classes/telegram/query/TSendVideoQuery.md), [TSendVoiceQuery](classes/telegram/query/TSendVoiceQuery.md), [TUnbanChatMemberQuery](classes/telegram/query/TUnbanChatMemberQuery.md)
+> [TAnswerCallbackQuery](classes/telegram/query/TAnswerCallbackQuery.md), [TEditMessageTextQuery](classes/telegram/query/TEditMessageTextQuery.md), [TForwardMessageQuery](classes/telegram/query/TForwardMessageQuery.md), [TGetFileQuery](classes/telegram/query/TGetFileQuery.md), [TGetMeQuery](classes/telegram/query/TGetMeQuery.md), [TGetUpdatesQuery](classes/telegram/query/TGetUpdatesQuery.md), [TGetUserProfilePhotosQuery](classes/telegram/query/TGetUserProfilePhotosQuery.md), [TKickChatMemberQuery](classes/telegram/query/TKickChatMemberQuery.md), [TSendAudioQuery](classes/telegram/query/TSendAudioQuery.md), [TSendChatActionQuery](classes/telegram/query/TSendChatActionQuery.md), [TSendContactQuery](classes/telegram/query/TSendContactQuery.md), [TSendDocumentQuery](classes/telegram/query/TSendDocumentQuery.md), [TSendLocationQuery](classes/telegram/query/TSendLocationQuery.md), [TSendMessageQuery](classes/telegram/query/TSendMessageQuery.md), [TSendPhotoQuery](classes/telegram/query/TSendPhotoQuery.md), [TSendStickerQuery](classes/telegram/query/TSendStickerQuery.md), [TSendVenueQuery](classes/telegram/query/TSendVenueQuery.md), [TSendVideoQuery](classes/telegram/query/TSendVideoQuery.md), [TSendVoiceQuery](classes/telegram/query/TSendVoiceQuery.md), [TUnbanChatMemberQuery](classes/telegram/query/TUnbanChatMemberQuery.md)
---
diff --git a/api-docs/classes/telegram/query/TSendMessageQuery.md b/api-docs/classes/telegram/query/TSendMessageQuery.md
index 94f2212..0055850 100644
--- a/api-docs/classes/telegram/query/TSendMessageQuery.md
+++ b/api-docs/classes/telegram/query/TSendMessageQuery.md
@@ -14,6 +14,7 @@
- `->`[`disable_web_page_preview()`](#method-disable_web_page_preview)
- `->`[`disable_notification()`](#method-disable_notification)
- `->`[`reply_to_message_id()`](#method-reply_to_message_id)
+- `->`[`reply_markup()`](#method-reply_markup)
- `->`[`query()`](#method-query)
- See also in the parent class [TBaseQuery](classes/telegram/query/TBaseQuery.md)
@@ -83,6 +84,15 @@ reply_to_message_id(mixed $value): TSendMessageQuery
---
+
+
+### reply_markup()
+```php
+reply_markup(mixed $value): TSendMessageQuery
+```
+
+---
+
### query()
diff --git a/package.build.php b/package.build.php
index c791220..3d9b7ab 100644
--- a/package.build.php
+++ b/package.build.php
@@ -8,7 +8,7 @@
/**
* @jppm-task create-bundle
*/
-function task_hubPublish(Event $e)
+function task_CreateBundle(Event $e)
{
$package = $e->package();
$data = $package->getAny('develnext-bundle');
diff --git a/package.php.yml b/package.php.yml
index 53d6076..db9ba38 100644
--- a/package.php.yml
+++ b/package.php.yml
@@ -1,5 +1,5 @@
name: telegram-bot-api
-version: 1.0.0
+version: 1.1.0
deps:
jphp-core: '*'
jphp-json-ext: '*'
@@ -12,6 +12,7 @@ sources:
plugins:
- Doc
- Hub
+- DevelNextBundle
config:
ignore:
@@ -19,6 +20,7 @@ config:
- /.idea/**
- /*.iml
- /.git/**
+ - /.phpintel/**
- /package.hub.yml
- /bundle/**
- /src-bundle/**
@@ -32,7 +34,7 @@ config:
- /LICENSE
develnext-bundle:
- version: 1.0.0
+ version: 1.1.0
name: Telegram Bot API
author: broelik
icon: "develnext/bundle/telegram/icon32.png"
diff --git a/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/TelegramBotApi.php b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/TelegramBotApi.php
index 6748bcf..c1f9e31 100644
--- a/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/TelegramBotApi.php
+++ b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/TelegramBotApi.php
@@ -17,6 +17,7 @@
use php\net\URLConnection;
use telegram\exception\TelegramError;
use telegram\exception\TelegramException;
+use telegram\query\TAnswerCallbackQuery;
use telegram\query\TForwardMessageQuery;
use telegram\query\TGetFileQuery;
use telegram\query\TGetMeQuery;
@@ -163,6 +164,13 @@ function getUpdates(){
return new TGetUpdatesQuery($this);
}
+ /**
+ * @return TAnswerCallbackQuery
+ */
+ function answerCallbackQuery(){
+ return new TAnswerCallbackQuery($this);
+ }
+
function setProxy(?Proxy $proxy){
$this->proxy = $proxy;
@@ -196,10 +204,14 @@ function query($method, array $args = [], bool $multipart = false){
else{
$connection->getOutputStream()->write($this->json->format($args));
}
+
if($connection->responseCode != 200){
- throw new TelegramException("Server response invalid status code {$connection->responseCode}");
+ $rawResponse = $connection->getErrorStream()->readFully();
+ if(strlen($rawResponse) == 0) throw new TelegramException("Server response invalid status code {$connection->responseCode}");
+ } else {
+ $rawResponse = $connection->getInputStream()->readFully();
}
- $rawResponse = $connection->getInputStream()->readFully();
+
$connection->disconnect();
$response = $this->json->parse($rawResponse);
if(!$response->ok){
diff --git a/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/TMarkup.php b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/TMarkup.php
new file mode 100644
index 0000000..3177605
--- /dev/null
+++ b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/TMarkup.php
@@ -0,0 +1,38 @@
+markup;
+ }
+}
\ No newline at end of file
diff --git a/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/markup/TForceReply.php b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/markup/TForceReply.php
new file mode 100644
index 0000000..6bdfe6c
--- /dev/null
+++ b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/markup/TForceReply.php
@@ -0,0 +1,25 @@
+markup['force_reply'] = true;
+ }
+
+ /**
+ * --EN--
+ * Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
+ *
+ * @param bool $value
+ */
+ public function setSelective(bool $value){
+ $this->markup['selective'] = $value;
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/markup/TInlineKeyboard.php b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/markup/TInlineKeyboard.php
new file mode 100644
index 0000000..bd6237a
--- /dev/null
+++ b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/markup/TInlineKeyboard.php
@@ -0,0 +1,61 @@
+ $text];
+
+ if(func_num_args() < 2){
+ throw new TelegramException('Parameter callback_data required for InlineKeyboard buttons');
+ } else {
+ $data = func_get_arg(1);
+ }
+
+ if(!is_string($data)){
+ throw new TelegramException('Parameter callback_data should be a string');
+ }
+
+ if(strpos($data, 'http:') === 0 || strpos($data, 'https:') === 0 || strpos($data, 'tg:') === 0){
+ $btn['url'] = $data;
+ } else {
+ if(strlen($data) > self::MAX_CBDATA_LENGTH){
+ throw new TelegramException('Parameter callback_data should be a string no more than ' . MAX_CBDATA_LENGTH . ' bytes in size');
+ }
+
+ $btn['callback_data'] = $data;
+ }
+
+ $this->buttons[$this->row][] = $btn;
+
+ return $this;
+ }
+
+ public function getMarkup(): array {
+ $markup = $this->params;
+ $markup['inline_keyboard'] = $this->buttons;
+
+ return $markup;
+ }
+}
\ No newline at end of file
diff --git a/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/markup/TReplyKeyboard.php b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/markup/TReplyKeyboard.php
new file mode 100644
index 0000000..cabbd77
--- /dev/null
+++ b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/markup/TReplyKeyboard.php
@@ -0,0 +1,99 @@
+params = $params;
+ $this->row();
+ }
+
+ /**
+ * Добавить новую строку в панель кнопок
+ * @return TReplyKeyboard
+ */
+ public function row(){
+ $this->row++;
+ if(!isset($this->buttons[$this->row])) $this->buttons[$this->row] = [];
+
+ return $this;
+ }
+
+ /**
+ * Добавить кнопку
+ * @param string $text Текст кнопки
+ * @return TReplyKeyboard
+ */
+ public function button(string $text){
+ $this->buttons[$this->row][] = ['text' => $text];
+
+ return $this;
+ }
+
+ /**
+ * Указывает клиенту подогнать высоту клавиатуры под количество кнопок
+ * (сделать её меньше, если кнопок мало и наоборот)
+ * @param bool $value
+ * @return TReplyKeyboard
+ */
+ public function setResize(bool $value){
+ $this->params['resize_keyboard'] = $value;
+ return $this;
+ }
+
+ /**
+ * Указывает клиенту скрыть клавиатуру после использования (после нажатия на кнопку).
+ * Её по-прежнему можно будет открыть через иконку в поле ввода сообщения.
+ * @param bool $value
+ * @return TReplyKeyboard
+ */
+ public function setOneTime(bool $value){
+ $this->params['one_time_keyboard'] = $value;
+ return $this;
+ }
+
+ /**
+ * @param bool $value
+ * @return TReplyKeyboard
+ */
+ public function setSelective(bool $value){
+ $this->params['selective'] = $value;
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getMarkup(): array {
+ $markup = $this->params;
+ $markup['keyboard'] = $this->buttons;
+
+ return $markup;
+ }
+}
\ No newline at end of file
diff --git a/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/markup/TReplyKeyboardRemove.php b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/markup/TReplyKeyboardRemove.php
new file mode 100644
index 0000000..17f61dd
--- /dev/null
+++ b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/object/markup/TReplyKeyboardRemove.php
@@ -0,0 +1,25 @@
+markup['remove_keyboard'] = true;
+ }
+
+ /**
+ * --EN--
+ * Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
+ *
+ * @param bool $value
+ */
+ public function setSelective(bool $value){
+ $this->markup['selective'] = $value;
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/query/TAnswerCallbackQuery.php b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/query/TAnswerCallbackQuery.php
new file mode 100644
index 0000000..d9803a0
--- /dev/null
+++ b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/query/TAnswerCallbackQuery.php
@@ -0,0 +1,78 @@
+put(__FUNCTION__, $value);
+ }
+
+ /**
+ * --EN--
+ * Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
+ *
+ * @param string $value
+ * @return TAnswerCallbackQuery
+ */
+ public function text(string $value){
+ return $this->put(__FUNCTION__, $value);
+ }
+
+ /**
+ * --EN--
+ * URL that will be opened by the user's client.
+ *
+ * @param string $value
+ * @return TAnswerCallbackQuery
+ */
+ public function url(string $value){
+ return $this->put(__FUNCTION__, $value);
+ }
+
+ /**
+ * --EN--
+ * If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
+ *
+ * @param string $value
+ * @return TAnswerCallbackQuery
+ */
+ public function show_alert(bool $value){
+ return $this->put(__FUNCTION__, $value);
+ }
+
+ /**
+ * --EN--
+ * The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
+ *
+ * @param string $value
+ * @return TAnswerCallbackQuery
+ */
+ public function cache_time(int $value){
+ return $this->put(__FUNCTION__, $value);
+ }
+}
\ No newline at end of file
diff --git a/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/query/TSendMessageQuery.php b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/query/TSendMessageQuery.php
index 6b7769b..acf2e4d 100644
--- a/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/query/TSendMessageQuery.php
+++ b/src-bundle/vendor/develnext.bundle.telegram.TelegramBotAPIBundle/telegram/query/TSendMessageQuery.php
@@ -4,8 +4,10 @@
namespace telegram\query;
-use telegram\object\TMessage;
use telegram\TelegramBotApi;
+use telegram\exception\TelegramException;
+use telegram\object\TMessage;
+use telegram\object\markup\AbstractMarkup;
class TSendMessageQuery extends TBaseQuery{
public function __construct(TelegramBotApi $api){
@@ -47,11 +49,23 @@ public function disable_notification($value){
public function reply_to_message_id($value){
return $this->put(__FUNCTION__, (int)$value);
}
- /*
+
+ /**
+ * @param array|TAbstractMarkup
+ * @return TSendMessageQuery
+ */
public function reply_markup($value){
- return $this->put(__FUNCTION__, $value);
+ if(is_array($value)){
+ return $this->put(__FUNCTION__, $value);
+ }
+ elseif($value instanceof AbstractMarkup){
+ return $this->put(__FUNCTION__, $value->getMarkup());
+ }
+ else {
+ throw new TelegramException('Invalid reply_markup parameter');
+ }
}
- */
+
/**
* @return TMessage
*/
diff --git a/src/telegram/TelegramBotApi.php b/src/telegram/TelegramBotApi.php
index 6748bcf..c1f9e31 100644
--- a/src/telegram/TelegramBotApi.php
+++ b/src/telegram/TelegramBotApi.php
@@ -17,6 +17,7 @@
use php\net\URLConnection;
use telegram\exception\TelegramError;
use telegram\exception\TelegramException;
+use telegram\query\TAnswerCallbackQuery;
use telegram\query\TForwardMessageQuery;
use telegram\query\TGetFileQuery;
use telegram\query\TGetMeQuery;
@@ -163,6 +164,13 @@ function getUpdates(){
return new TGetUpdatesQuery($this);
}
+ /**
+ * @return TAnswerCallbackQuery
+ */
+ function answerCallbackQuery(){
+ return new TAnswerCallbackQuery($this);
+ }
+
function setProxy(?Proxy $proxy){
$this->proxy = $proxy;
@@ -196,10 +204,14 @@ function query($method, array $args = [], bool $multipart = false){
else{
$connection->getOutputStream()->write($this->json->format($args));
}
+
if($connection->responseCode != 200){
- throw new TelegramException("Server response invalid status code {$connection->responseCode}");
+ $rawResponse = $connection->getErrorStream()->readFully();
+ if(strlen($rawResponse) == 0) throw new TelegramException("Server response invalid status code {$connection->responseCode}");
+ } else {
+ $rawResponse = $connection->getInputStream()->readFully();
}
- $rawResponse = $connection->getInputStream()->readFully();
+
$connection->disconnect();
$response = $this->json->parse($rawResponse);
if(!$response->ok){
diff --git a/src/telegram/object/TMarkup.php b/src/telegram/object/TMarkup.php
new file mode 100644
index 0000000..3177605
--- /dev/null
+++ b/src/telegram/object/TMarkup.php
@@ -0,0 +1,38 @@
+markup;
+ }
+}
\ No newline at end of file
diff --git a/src/telegram/object/markup/TForceReply.php b/src/telegram/object/markup/TForceReply.php
new file mode 100644
index 0000000..6bdfe6c
--- /dev/null
+++ b/src/telegram/object/markup/TForceReply.php
@@ -0,0 +1,25 @@
+markup['force_reply'] = true;
+ }
+
+ /**
+ * --EN--
+ * Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
+ *
+ * @param bool $value
+ */
+ public function setSelective(bool $value){
+ $this->markup['selective'] = $value;
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/telegram/object/markup/TInlineKeyboard.php b/src/telegram/object/markup/TInlineKeyboard.php
new file mode 100644
index 0000000..bd6237a
--- /dev/null
+++ b/src/telegram/object/markup/TInlineKeyboard.php
@@ -0,0 +1,61 @@
+ $text];
+
+ if(func_num_args() < 2){
+ throw new TelegramException('Parameter callback_data required for InlineKeyboard buttons');
+ } else {
+ $data = func_get_arg(1);
+ }
+
+ if(!is_string($data)){
+ throw new TelegramException('Parameter callback_data should be a string');
+ }
+
+ if(strpos($data, 'http:') === 0 || strpos($data, 'https:') === 0 || strpos($data, 'tg:') === 0){
+ $btn['url'] = $data;
+ } else {
+ if(strlen($data) > self::MAX_CBDATA_LENGTH){
+ throw new TelegramException('Parameter callback_data should be a string no more than ' . MAX_CBDATA_LENGTH . ' bytes in size');
+ }
+
+ $btn['callback_data'] = $data;
+ }
+
+ $this->buttons[$this->row][] = $btn;
+
+ return $this;
+ }
+
+ public function getMarkup(): array {
+ $markup = $this->params;
+ $markup['inline_keyboard'] = $this->buttons;
+
+ return $markup;
+ }
+}
\ No newline at end of file
diff --git a/src/telegram/object/markup/TReplyKeyboard.php b/src/telegram/object/markup/TReplyKeyboard.php
new file mode 100644
index 0000000..cabbd77
--- /dev/null
+++ b/src/telegram/object/markup/TReplyKeyboard.php
@@ -0,0 +1,99 @@
+params = $params;
+ $this->row();
+ }
+
+ /**
+ * Добавить новую строку в панель кнопок
+ * @return TReplyKeyboard
+ */
+ public function row(){
+ $this->row++;
+ if(!isset($this->buttons[$this->row])) $this->buttons[$this->row] = [];
+
+ return $this;
+ }
+
+ /**
+ * Добавить кнопку
+ * @param string $text Текст кнопки
+ * @return TReplyKeyboard
+ */
+ public function button(string $text){
+ $this->buttons[$this->row][] = ['text' => $text];
+
+ return $this;
+ }
+
+ /**
+ * Указывает клиенту подогнать высоту клавиатуры под количество кнопок
+ * (сделать её меньше, если кнопок мало и наоборот)
+ * @param bool $value
+ * @return TReplyKeyboard
+ */
+ public function setResize(bool $value){
+ $this->params['resize_keyboard'] = $value;
+ return $this;
+ }
+
+ /**
+ * Указывает клиенту скрыть клавиатуру после использования (после нажатия на кнопку).
+ * Её по-прежнему можно будет открыть через иконку в поле ввода сообщения.
+ * @param bool $value
+ * @return TReplyKeyboard
+ */
+ public function setOneTime(bool $value){
+ $this->params['one_time_keyboard'] = $value;
+ return $this;
+ }
+
+ /**
+ * @param bool $value
+ * @return TReplyKeyboard
+ */
+ public function setSelective(bool $value){
+ $this->params['selective'] = $value;
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getMarkup(): array {
+ $markup = $this->params;
+ $markup['keyboard'] = $this->buttons;
+
+ return $markup;
+ }
+}
\ No newline at end of file
diff --git a/src/telegram/object/markup/TReplyKeyboardRemove.php b/src/telegram/object/markup/TReplyKeyboardRemove.php
new file mode 100644
index 0000000..17f61dd
--- /dev/null
+++ b/src/telegram/object/markup/TReplyKeyboardRemove.php
@@ -0,0 +1,25 @@
+markup['remove_keyboard'] = true;
+ }
+
+ /**
+ * --EN--
+ * Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
+ *
+ * @param bool $value
+ */
+ public function setSelective(bool $value){
+ $this->markup['selective'] = $value;
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/src/telegram/query/TAnswerCallbackQuery.php b/src/telegram/query/TAnswerCallbackQuery.php
new file mode 100644
index 0000000..d9803a0
--- /dev/null
+++ b/src/telegram/query/TAnswerCallbackQuery.php
@@ -0,0 +1,78 @@
+put(__FUNCTION__, $value);
+ }
+
+ /**
+ * --EN--
+ * Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
+ *
+ * @param string $value
+ * @return TAnswerCallbackQuery
+ */
+ public function text(string $value){
+ return $this->put(__FUNCTION__, $value);
+ }
+
+ /**
+ * --EN--
+ * URL that will be opened by the user's client.
+ *
+ * @param string $value
+ * @return TAnswerCallbackQuery
+ */
+ public function url(string $value){
+ return $this->put(__FUNCTION__, $value);
+ }
+
+ /**
+ * --EN--
+ * If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
+ *
+ * @param string $value
+ * @return TAnswerCallbackQuery
+ */
+ public function show_alert(bool $value){
+ return $this->put(__FUNCTION__, $value);
+ }
+
+ /**
+ * --EN--
+ * The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
+ *
+ * @param string $value
+ * @return TAnswerCallbackQuery
+ */
+ public function cache_time(int $value){
+ return $this->put(__FUNCTION__, $value);
+ }
+}
\ No newline at end of file
diff --git a/src/telegram/query/TSendMessageQuery.php b/src/telegram/query/TSendMessageQuery.php
index 6b7769b..acf2e4d 100644
--- a/src/telegram/query/TSendMessageQuery.php
+++ b/src/telegram/query/TSendMessageQuery.php
@@ -4,8 +4,10 @@
namespace telegram\query;
-use telegram\object\TMessage;
use telegram\TelegramBotApi;
+use telegram\exception\TelegramException;
+use telegram\object\TMessage;
+use telegram\object\markup\AbstractMarkup;
class TSendMessageQuery extends TBaseQuery{
public function __construct(TelegramBotApi $api){
@@ -47,11 +49,23 @@ public function disable_notification($value){
public function reply_to_message_id($value){
return $this->put(__FUNCTION__, (int)$value);
}
- /*
+
+ /**
+ * @param array|TAbstractMarkup
+ * @return TSendMessageQuery
+ */
public function reply_markup($value){
- return $this->put(__FUNCTION__, $value);
+ if(is_array($value)){
+ return $this->put(__FUNCTION__, $value);
+ }
+ elseif($value instanceof AbstractMarkup){
+ return $this->put(__FUNCTION__, $value->getMarkup());
+ }
+ else {
+ throw new TelegramException('Invalid reply_markup parameter');
+ }
}
- */
+
/**
* @return TMessage
*/