Commit 6fea113e authored by smoqadam's avatar smoqadam

Merge branch 'develop' of github.com:php-telegram-bot/core into develop

# Conflicts:
#	README.md
parents 32b47a05 112049b5
...@@ -204,7 +204,7 @@ require __DIR__ . '/vendor/autoload.php'; ...@@ -204,7 +204,7 @@ require __DIR__ . '/vendor/autoload.php';
$bot_api_key = 'your:bot_api_key'; $bot_api_key = 'your:bot_api_key';
$bot_username = 'username_bot'; $bot_username = 'username_bot';
$hook_url = 'https://your-domain/path/to/hook.php'; $hook_url = 'https://your-domain/path/to/hook.php';
try { try {
// Create Telegram API object // Create Telegram API object
...@@ -269,6 +269,7 @@ require __DIR__ . '/vendor/autoload.php'; ...@@ -269,6 +269,7 @@ require __DIR__ . '/vendor/autoload.php';
$bot_api_key = 'your:bot_api_key'; $bot_api_key = 'your:bot_api_key';
$bot_username = 'username_bot'; $bot_username = 'username_bot';
$mysql_credentials = [ $mysql_credentials = [
'host' => 'localhost', 'host' => 'localhost',
'user' => 'dbuser', 'user' => 'dbuser',
...@@ -327,7 +328,10 @@ All methods are implemented according to Telegram API (20 January 2016). ...@@ -327,7 +328,10 @@ All methods are implemented according to Telegram API (20 January 2016).
Messages longer than 4096 characters are split up into multiple messages. Messages longer than 4096 characters are split up into multiple messages.
```php ```php
$result = Request::sendMessage(['chat_id' => $chat_id, 'text' => 'Your utf8 text 😜 ...']); $result = Request::sendMessage([
'chat_id' => $chat_id,
'text' => 'Your utf8 text 😜 ...',
]);
``` ```
#### Send Photo #### Send Photo
...@@ -335,31 +339,28 @@ $result = Request::sendMessage(['chat_id' => $chat_id, 'text' => 'Your utf8 text ...@@ -335,31 +339,28 @@ $result = Request::sendMessage(['chat_id' => $chat_id, 'text' => 'Your utf8 text
To send a local photo, add it properly to the `$data` parameter using the file path: To send a local photo, add it properly to the `$data` parameter using the file path:
```php ```php
$data = [ $result = Request::sendPhoto([
'chat_id' => $chat_id, 'chat_id' => $chat_id,
'photo' => Request::encodeFile('/path/to/pic.jpg'), 'photo' => Request::encodeFile('/path/to/pic.jpg'),
]; ]);
$result = Request::sendPhoto($data);
``` ```
If you know the `file_id` of a previously uploaded file, just use it directly in the data array: If you know the `file_id` of a previously uploaded file, just use it directly in the data array:
```php ```php
$data = [ $result = Request::sendPhoto([
'chat_id' => $chat_id, 'chat_id' => $chat_id,
'photo' => $file_id, 'photo' => 'AAQCCBNtIhAoAAss4tLEZ3x6HzqVAAqC',
]; ]);
$result = Request::sendPhoto($data);
``` ```
To send a remote photo, use the direct URL instead: To send a remote photo, use the direct URL instead:
```php ```php
$data = [ $result = Request::sendPhoto([
'chat_id' => $chat_id, 'chat_id' => $chat_id,
'photo' => 'https://example.com/path/to/pic.jpg', 'photo' => 'https://example.com/path/to/pic.jpg',
]; ]);
$result = Request::sendPhoto($data);
``` ```
*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. *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,8 +370,8 @@ See the [*ImageCommand.php*][ImageCommand.php] for a full example. ...@@ -369,8 +370,8 @@ See the [*ImageCommand.php*][ImageCommand.php] for a full example.
```php ```php
Request::sendChatAction([ Request::sendChatAction([
'chat_id' => $chat_id, 'chat_id' => $chat_id,
'action' => Longman\TelegramBot\Telegram::ACTION_TYPING 'action' => 'typing',
]); ]);
``` ```
...@@ -505,10 +506,14 @@ With this method you can set some command specific parameters, for example: ...@@ -505,10 +506,14 @@ With this method you can set some command specific parameters, for example:
```php ```php
// Google geocode/timezone API key for /date command // Google geocode/timezone API key for /date command
$telegram->setCommandConfig('date', ['google_api_key' => 'your_google_api_key_here']); $telegram->setCommandConfig('date', [
'google_api_key' => 'your_google_api_key_here',
]);
// OpenWeatherMap API key for /weather command // OpenWeatherMap API key for /weather command
$telegram->setCommandConfig('weather', ['owm_api_key' => 'your_owm_api_key_here']); $telegram->setCommandConfig('weather', [
'owm_api_key' => 'your_owm_api_key_here',
]);
``` ```
### Admin Commands ### Admin Commands
...@@ -532,7 +537,10 @@ You can specify one or more admins with this option: ...@@ -532,7 +537,10 @@ You can specify one or more admins with this option:
$telegram->enableAdmin(your_telegram_user_id); $telegram->enableAdmin(your_telegram_user_id);
// Multiple admins // Multiple admins
$telegram->enableAdmins([your_telegram_user_id, other_telegram_user_id]); $telegram->enableAdmins([
your_telegram_user_id,
other_telegram_user_id,
]);
``` ```
Telegram user id can be retrieved with the [*/whoami*][WhoamiCommand.php] command. Telegram user id can be retrieved with the [*/whoami*][WhoamiCommand.php] command.
...@@ -543,11 +551,21 @@ To enable this feature follow these steps: ...@@ -543,11 +551,21 @@ To enable this feature follow these steps:
- Enable admin interface for your user as explained in the admin section above. - Enable admin interface for your user as explained in the admin section above.
- Enter your channel name as a parameter for the [*/sendtochannel*][SendtochannelCommand.php] command: - Enter your channel name as a parameter for the [*/sendtochannel*][SendtochannelCommand.php] command:
```php ```php
$telegram->setCommandConfig('sendtochannel', ['your_channel' => ['@type_here_your_channel']]); $telegram->setCommandConfig('sendtochannel', [
'your_channel' => [
'@type_here_your_channel',
]
]);
``` ```
- If you want to manage more channels: - If you want to manage more channels:
```php ```php
$telegram->setCommandConfig('sendtochannel', ['your_channel' => ['@type_here_your_channel', '@type_here_another_channel', '@and_so_on']]); $telegram->setCommandConfig('sendtochannel', [
'your_channel' => [
'@type_here_your_channel',
'@type_here_another_channel',
'@and_so_on',
]
]);
``` ```
- Enjoy! - Enjoy!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment