Skip to content

Commit 52ff929

Browse files
authored
Merge branch 'develop' into 857-mysql_port
2 parents 6a0828f + 112049b commit 52ff929

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

README.md

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ require __DIR__ . '/vendor/autoload.php';
204204

205205
$bot_api_key = 'your:bot_api_key';
206206
$bot_username = 'username_bot';
207-
$hook_url = 'https://your-domain/path/to/hook.php';
207+
$hook_url = 'https://your-domain/path/to/hook.php';
208208

209209
try {
210210
// Create Telegram API object
@@ -269,6 +269,7 @@ require __DIR__ . '/vendor/autoload.php';
269269

270270
$bot_api_key = 'your:bot_api_key';
271271
$bot_username = 'username_bot';
272+
272273
$mysql_credentials = [
273274
'host' => 'localhost',
274275
'port' => 3306, // optional
@@ -328,39 +329,39 @@ All methods are implemented according to Telegram API (20 January 2016).
328329
Messages longer than 4096 characters are split up into multiple messages.
329330

330331
```php
331-
$result = Request::sendMessage(['chat_id' => $chat_id, 'text' => 'Your utf8 text 😜 ...']);
332+
$result = Request::sendMessage([
333+
'chat_id' => $chat_id,
334+
'text' => 'Your utf8 text 😜 ...',
335+
]);
332336
```
333337

334338
#### Send Photo
335339

336340
To send a local photo, add it properly to the `$data` parameter using the file path:
337341

338342
```php
339-
$data = [
343+
$result = Request::sendPhoto([
340344
'chat_id' => $chat_id,
341345
'photo' => Request::encodeFile('/path/to/pic.jpg'),
342-
];
343-
$result = Request::sendPhoto($data);
346+
]);
344347
```
345348

346349
If you know the `file_id` of a previously uploaded file, just use it directly in the data array:
347350

348351
```php
349-
$data = [
352+
$result = Request::sendPhoto([
350353
'chat_id' => $chat_id,
351-
'photo' => $file_id,
352-
];
353-
$result = Request::sendPhoto($data);
354+
'photo' => 'AAQCCBNtIhAoAAss4tLEZ3x6HzqVAAqC',
355+
]);
354356
```
355357

356358
To send a remote photo, use the direct URL instead:
357359

358360
```php
359-
$data = [
361+
$result = Request::sendPhoto([
360362
'chat_id' => $chat_id,
361363
'photo' => 'https://example.com/path/to/pic.jpg',
362-
];
363-
$result = Request::sendPhoto($data);
364+
]);
364365
```
365366

366367
*sendAudio*, *sendDocument*, *sendSticker*, *sendVideo*, *sendVoice* and *sendVideoNote* all work in the same way, just check the [API documentation](https://core.telegram.org/bots/api#sendphoto) for the exact usage.
@@ -369,7 +370,10 @@ See the [*ImageCommand.php*][ImageCommand.php] for a full example.
369370
#### Send Chat Action
370371

371372
```php
372-
Request::sendChatAction(['chat_id' => $chat_id, 'action' => 'typing']);
373+
Request::sendChatAction([
374+
'chat_id' => $chat_id,
375+
'action' => 'typing',
376+
]);
373377
```
374378

375379
#### getUserProfilePhoto
@@ -504,10 +508,14 @@ With this method you can set some command specific parameters, for example:
504508

505509
```php
506510
// Google geocode/timezone API key for /date command
507-
$telegram->setCommandConfig('date', ['google_api_key' => 'your_google_api_key_here']);
511+
$telegram->setCommandConfig('date', [
512+
'google_api_key' => 'your_google_api_key_here',
513+
]);
508514

509515
// OpenWeatherMap API key for /weather command
510-
$telegram->setCommandConfig('weather', ['owm_api_key' => 'your_owm_api_key_here']);
516+
$telegram->setCommandConfig('weather', [
517+
'owm_api_key' => 'your_owm_api_key_here',
518+
]);
511519
```
512520

513521
### Admin Commands
@@ -531,7 +539,10 @@ You can specify one or more admins with this option:
531539
$telegram->enableAdmin(your_telegram_user_id);
532540

533541
// Multiple admins
534-
$telegram->enableAdmins([your_telegram_user_id, other_telegram_user_id]);
542+
$telegram->enableAdmins([
543+
your_telegram_user_id,
544+
other_telegram_user_id,
545+
]);
535546
```
536547
Telegram user id can be retrieved with the [*/whoami*][WhoamiCommand.php] command.
537548

@@ -542,11 +553,21 @@ To enable this feature follow these steps:
542553
- Enable admin interface for your user as explained in the admin section above.
543554
- Enter your channel name as a parameter for the [*/sendtochannel*][SendtochannelCommand.php] command:
544555
```php
545-
$telegram->setCommandConfig('sendtochannel', ['your_channel' => ['@type_here_your_channel']]);
556+
$telegram->setCommandConfig('sendtochannel', [
557+
'your_channel' => [
558+
'@type_here_your_channel',
559+
]
560+
]);
546561
```
547562
- If you want to manage more channels:
548563
```php
549-
$telegram->setCommandConfig('sendtochannel', ['your_channel' => ['@type_here_your_channel', '@type_here_another_channel', '@and_so_on']]);
564+
$telegram->setCommandConfig('sendtochannel', [
565+
'your_channel' => [
566+
'@type_here_your_channel',
567+
'@type_here_another_channel',
568+
'@and_so_on',
569+
]
570+
]);
550571
```
551572
- Enjoy!
552573

0 commit comments

Comments
 (0)