Skip to content
This repository was archived by the owner on Mar 8, 2019. It is now read-only.

Commit 8cd496d

Browse files
author
Tsvetkov
committed
Merge branch 'release/1.1.0'
2 parents 5d4adc2 + 61c16da commit 8cd496d

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

src/TelegramBot.php

+37-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
class TelegramBot
1717
{
1818
/** @var string */
19-
private $token;
19+
protected $token;
2020

2121
/** @var string */
22-
private $baseUrl;
22+
protected $baseUrl;
2323

2424
/** @var array */
25-
private $requestOptions;
25+
protected $requestOptions;
2626

2727
/**
2828
* TelegramBot constructor.
@@ -52,7 +52,7 @@ public function __construct($token, $proxyConfig = null, $ipResolve = null)
5252
* @param bool $returnContent
5353
* @return bool|string
5454
*/
55-
private function makeRequest($url, $data = null, $files = null, $returnContent = false)
55+
protected function makeRequest($url, $data = null, $files = null, $returnContent = false)
5656
{
5757
try {
5858
$client = new Client();
@@ -149,6 +149,39 @@ public function sendPhoto($chat_id, $photo, $caption = null, $parse_mode = null,
149149
return $this->makeRequest($this->baseUrl . '/sendPhoto', $data, ['photo' => $photo]);
150150
}
151151

152+
/**
153+
* Official docs: https://core.telegram.org/bots/api#senddocument
154+
* Max size document is 50 MB
155+
* @param integer|string $chat_id
156+
* @param string $document Path to file
157+
* @param string $thumb Path to file
158+
* @param null $caption
159+
* @param string $parse_mode
160+
* @param bool $disable_notification
161+
* @param integer $reply_to_message_id
162+
* @param $reply_markup
163+
* @return bool
164+
*/
165+
public function sendDocument($chat_id, $document, $thumb = null, $caption = null, $parse_mode = null, $disable_notification = null, $reply_to_message_id = null, $reply_markup = null)
166+
{
167+
if (!in_array(strtolower($parse_mode), ['markdown', 'html', null])) {
168+
throw new \InvalidArgumentException('Invalid parse_mode argument');
169+
}
170+
$data = [
171+
'chat_id' => $chat_id,
172+
'caption' => $caption,
173+
'parse_mode' => $parse_mode,
174+
'disable_notification' => $disable_notification,
175+
'reply_to_message_id' => $reply_to_message_id,
176+
'reply_markup' => $reply_markup,
177+
];
178+
$files['document'] = $document;
179+
if (!is_null($thumb)) {
180+
$files['thumb'] = $thumb;
181+
}
182+
return $this->makeRequest($this->baseUrl . '/sendDocument', $data, $files);
183+
}
184+
152185
/**
153186
* @param $url
154187
* @param null $certificate

0 commit comments

Comments
 (0)