Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
/gradlew.bat
/package-lock.php.yml
/out/**
/dn-sources/**
/dn-sources/**
.phpintel/**
67 changes: 67 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,73 @@ $listener->addListener(function($update){
});
$listener->start();
```
### Использование клавиатуры
#### Клавиатура под полем ввода (ReplyKeyboard)
![ReplyKeyboard](https://sun9-45.userapi.com/c205624/v205624150/12151/u119tArN_LE.jpg)
```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)
![InlineKeyboard](https://sun9-59.userapi.com/c205624/v205624829/11e6f/itNoz8qnyFE.jpg)
```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)
![ForceReply](https://sun9-23.userapi.com/c205624/v205624829/11e98/pyW0VWHtPJ0.jpg)
```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)

Expand Down
14 changes: 12 additions & 2 deletions api-docs/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions api-docs/classes/telegram/TelegramBotApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -217,6 +218,15 @@ getUpdates(): TGetUpdatesQuery

---

<a name="method-answercallbackquery"></a>

### answerCallbackQuery()
```php
answerCallbackQuery(): TAnswerCallbackQuery
```

---

<a name="method-setproxy"></a>

### setProxy()
Expand Down
50 changes: 50 additions & 0 deletions api-docs/classes/telegram/object/TMarkup.md
Original file line number Diff line number Diff line change
@@ -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

<a name="method-replykeyboard"></a>

### replyKeyboard()
```php
TMarkup::replyKeyboard(): TReplyKeyboard
```

---

<a name="method-inlinekeyboard"></a>

### inlineKeyboard()
```php
TMarkup::inlineKeyboard(): TInlineKeyboard
```

---

<a name="method-forcereply"></a>

### forceReply()
```php
TMarkup::forceReply(): TForceReply
```

---

<a name="method-removekeyboard"></a>

### removeKeyboard()
```php
TMarkup::removeKeyboard(): TReplyKeyboardRemove
```
30 changes: 30 additions & 0 deletions api-docs/classes/telegram/object/markup/AbstractMarkup.md
Original file line number Diff line number Diff line change
@@ -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

<a name="method-getmarkup"></a>

### getMarkup()
```php
getMarkup(): array
```
36 changes: 36 additions & 0 deletions api-docs/classes/telegram/object/markup/TForceReply.md
Original file line number Diff line number Diff line change
@@ -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

<a name="method-__construct"></a>

### __construct()
```php
__construct(): void
```

---

<a name="method-setselective"></a>

### 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.
37 changes: 37 additions & 0 deletions api-docs/classes/telegram/object/markup/TInlineKeyboard.md
Original file line number Diff line number Diff line change
@@ -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

<a name="method-button"></a>

### button()
```php
button(string $text): TInlineKeyboard
```
Добавить кнопку

---

<a name="method-getmarkup"></a>

### getMarkup()
```php
getMarkup(): array
```
Loading