Skip to content

Commit a86adc3

Browse files
committed
Update readme and add the new config structure.
1 parent 0163bab commit a86adc3

File tree

2 files changed

+45
-17
lines changed

2 files changed

+45
-17
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
44
## [Unreleased]
55
### Added
66
- Ability to define custom valid IPs to access webhook.
7+
### Changed
8+
- Remodelled the config array to a more flexible structure.
9+
### Deprecated
10+
### Removed
11+
### Fixed
12+
### Security
713

814
## [0.43.0] - 2017-04-17
915
### Added

README.md

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ and then run `composer update`
4040

4141
What use would this library be if you couldn't perform any actions?!
4242

43-
There are 3 parameters available to get things rolling:
43+
There are 4 parameters available to get things rolling:
4444

4545
| Parameter | Description |
4646
| --------- | ----------- |
@@ -109,7 +109,7 @@ Let's start off with a simple example that uses the Webhook method:
109109
use NPM\TelegramBotManager\BotManager;
110110

111111
// Load composer.
112-
require __DIR__ . '/vendor/autoload.php';
112+
require_once __DIR__ . '/vendor/autoload.php';
113113

114114
try {
115115
$bot = new BotManager([
@@ -119,7 +119,9 @@ try {
119119
'secret' => 'super_secret',
120120

121121
// Extras.
122-
'webhook' => 'https://example.com/manager.php',
122+
'webhook' => [
123+
'url' => 'https://example.com/manager.php',
124+
]
123125
]);
124126
$bot->run();
125127
} catch (\Exception $e) {
@@ -159,32 +161,52 @@ Here is a list of available extra parameters:
159161
| *bool* | *default is `true`* |
160162
| valid_ips | When using `validate_request`, also allow these IPs (single, CIDR, wildcard, range). |
161163
| *array* | *e.g.* `['1.2.3.4', '192.168.1.0/24', '10/8', '5.6.*', '1.1.1.1-2.2.2.2']` |
162-
| webhook | URL to the manager PHP file used for setting up the Webhook. |
164+
| webhook | All options that have to do with the webhook. |
165+
| *array* | *Array keys listed below* |
166+
| - url | URL to the manager PHP file used for setting up the Webhook. |
163167
| *string* | *e.g.* `'https://example.com/manager.php'` |
164-
| certificate | Path to a self-signed certificate (if necessary). |
168+
| - certificate | Path to a self-signed certificate (if necessary). |
165169
| *string* | *e.g.* `__DIR__ . '/server.crt'` |
166-
| max_connections | Maximum allowed simultaneous HTTPS connections to the webhook. |
170+
| - max_connections | Maximum allowed simultaneous HTTPS connections to the webhook. |
167171
| *int* | *e.g.* `20` |
168-
| allowed_updates | List the types of updates you want your bot to receive. |
172+
| - allowed_updates | List the types of updates you want your bot to receive. |
169173
| *array* | *e.g.* `['message', 'edited_channel_post', 'callback_query']` |
170-
| logging | Path(s) where to the log files should be put. This is an array that can contain all 3 log file paths (`error`, `debug` and `update`). |
171-
| *array* | *e.g.* `['error' => __DIR__ . '/php-telegram-bot-error.log']` |
172-
| limiter | Enable or disable the limiter functionality, also accepts options array. |
173-
| *bool|array* | *e.g.* `true` or `false` or `['interval' => 2]` |
174+
| logging | Paths where the log files should be put. |
175+
| *array* | *Array keys listed below* |
176+
| - update | Log file for all incoming update requests. |
177+
| *string* | *e.g.* `__DIR__ . '/php-telegram-bot-update.log'` |
178+
| - debug | Log file for debug purposes. |
179+
| *string* | *e.g.* `__DIR__ . '/php-telegram-bot-debug.log'` |
180+
| - error | Log file for all errors. |
181+
| *string* | *e.g.* `__DIR__ . '/php-telegram-bot-error.log'` |
182+
| limiter | All options that have to do with the limiter. |
183+
| *array* | *Array keys listed below* |
184+
| - enabled | Enable or disable the limiter functionality. |
185+
| *bool* | *e.g.* `true` or `false` |
186+
| - options | Any extra options to pass to the limiter. |
187+
| *array* | *e.g.* `['interval' => 0.5]` |
174188
| admins | An array of user ids that have admin access to your bot. |
175189
| *array* | *e.g.* `[12345]` |
176190
| mysql | Mysql credentials to connect a database (necessary for [`getUpdates`](#using-getupdates-method) method!). |
177191
| *array* | *e.g.* `['host' => '127.0.0.1', 'user' => 'root', 'password' => 'root', 'database' => 'telegram_bot']` |
178-
| download_path | Custom download path. |
192+
| paths | List of configurable paths. |
193+
| *array* | *Array keys listed below* |
194+
| - download | Custom download path. |
179195
| *string* | *e.g.* `__DIR__ . '/Download'` |
180-
| upload_path | Custom upload path. |
196+
| - upload | Custom upload path. |
181197
| *string* | *e.g.* `__DIR__ . '/Upload'` |
182-
| commands_paths | A list of custom commands paths. |
198+
| commands | All options that have to do with commands. |
199+
| *array* | *Array keys listed below* |
200+
| - paths | A list of custom commands paths. |
183201
| *array* | *e.g.* `[__DIR__ . '/CustomCommands']` |
184-
| command_configs | A list of all custom command configs. |
185-
| *array* | *e.g.* `['sendtochannel' => ['your_channel' => '@my_channel']` |
186-
| botan_token | The Botan.io token to be used for analytics. |
202+
| - configs | A list of all custom command configs. |
203+
| *array* | *e.g.* `['sendtochannel' => ['your_channel' => '@my_channel'], 'weather' => ['owm_api_key' => 'owm_api_key_12345']]` |
204+
| botan | All options that have to do with botan. |
205+
| *array* | *Array keys listed below* |
206+
| - token | The Botan.io token to be used for analytics. |
187207
| *string* | *e.g.* `'botan_12345'` |
208+
| - options | Any extra options to pass to botan. |
209+
| *array* | *e.g.* `['timeout' => 3]` |
188210
| custom_input | Override the custom input of your bot (mostly for testing purposes!). |
189211
| *string* | *e.g.* `'{"some":"raw", "json":"update"}'` |
190212

0 commit comments

Comments
 (0)