Skip to content

Commit c9146a6

Browse files
authored
Merge branch 'develop' into 726-games
2 parents dff8f6d + 112049b commit c9146a6

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
'user' => 'dbuser',
@@ -327,39 +328,39 @@ All methods are implemented according to Telegram API (20 January 2016).
327328
Messages longer than 4096 characters are split up into multiple messages.
328329

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

333337
#### Send Photo
334338

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

337341
```php
338-
$data = [
342+
$result = Request::sendPhoto([
339343
'chat_id' => $chat_id,
340344
'photo' => Request::encodeFile('/path/to/pic.jpg'),
341-
];
342-
$result = Request::sendPhoto($data);
345+
]);
343346
```
344347

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

347350
```php
348-
$data = [
351+
$result = Request::sendPhoto([
349352
'chat_id' => $chat_id,
350-
'photo' => $file_id,
351-
];
352-
$result = Request::sendPhoto($data);
353+
'photo' => 'AAQCCBNtIhAoAAss4tLEZ3x6HzqVAAqC',
354+
]);
353355
```
354356

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

357359
```php
358-
$data = [
360+
$result = Request::sendPhoto([
359361
'chat_id' => $chat_id,
360362
'photo' => 'https://example.com/path/to/pic.jpg',
361-
];
362-
$result = Request::sendPhoto($data);
363+
]);
363364
```
364365

365366
*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.
@@ -368,7 +369,10 @@ See the [*ImageCommand.php*][ImageCommand.php] for a full example.
368369
#### Send Chat Action
369370

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

374378
#### getUserProfilePhoto
@@ -502,10 +506,14 @@ With this method you can set some command specific parameters, for example:
502506

503507
```php
504508
// Google geocode/timezone API key for /date command
505-
$telegram->setCommandConfig('date', ['google_api_key' => 'your_google_api_key_here']);
509+
$telegram->setCommandConfig('date', [
510+
'google_api_key' => 'your_google_api_key_here',
511+
]);
506512

507513
// OpenWeatherMap API key for /weather command
508-
$telegram->setCommandConfig('weather', ['owm_api_key' => 'your_owm_api_key_here']);
514+
$telegram->setCommandConfig('weather', [
515+
'owm_api_key' => 'your_owm_api_key_here',
516+
]);
509517
```
510518

511519
### Admin Commands
@@ -529,7 +537,10 @@ You can specify one or more admins with this option:
529537
$telegram->enableAdmin(your_telegram_user_id);
530538

531539
// Multiple admins
532-
$telegram->enableAdmins([your_telegram_user_id, other_telegram_user_id]);
540+
$telegram->enableAdmins([
541+
your_telegram_user_id,
542+
other_telegram_user_id,
543+
]);
533544
```
534545
Telegram user id can be retrieved with the [*/whoami*][WhoamiCommand.php] command.
535546

@@ -540,11 +551,21 @@ To enable this feature follow these steps:
540551
- Enable admin interface for your user as explained in the admin section above.
541552
- Enter your channel name as a parameter for the [*/sendtochannel*][SendtochannelCommand.php] command:
542553
```php
543-
$telegram->setCommandConfig('sendtochannel', ['your_channel' => ['@type_here_your_channel']]);
554+
$telegram->setCommandConfig('sendtochannel', [
555+
'your_channel' => [
556+
'@type_here_your_channel',
557+
]
558+
]);
544559
```
545560
- If you want to manage more channels:
546561
```php
547-
$telegram->setCommandConfig('sendtochannel', ['your_channel' => ['@type_here_your_channel', '@type_here_another_channel', '@and_so_on']]);
562+
$telegram->setCommandConfig('sendtochannel', [
563+
'your_channel' => [
564+
'@type_here_your_channel',
565+
'@type_here_another_channel',
566+
'@and_so_on',
567+
]
568+
]);
548569
```
549570
- Enjoy!
550571

0 commit comments

Comments
 (0)