Skip to content

Commit 6cd9240

Browse files
committed
Update readme and use a PHP example to explain the parameters instead of a table.
[skip ci]
1 parent a86adc3 commit 6cd9240

File tree

1 file changed

+111
-60
lines changed

1 file changed

+111
-60
lines changed

README.md

Lines changed: 111 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,21 @@ try {
132132
### Set vital bot parameters
133133

134134
The vital parameters are:
135-
- Bot API key
136-
- Bot username
137-
- A secret
138135

139-
What secret you ask? Well, this is a user-defined key that is required to execute any of the library features.
136+
```php
137+
$bot = new BotManager([
138+
// (string) Bot API key provided by @BotFather.
139+
'api_key' => '12345:my_api_key',
140+
// (string) Bot username that was defined when creating the bot.
141+
'bot_username' => 'my_own_bot',
142+
// (string) A secret password required to authorise access to the webhook.
143+
'secret' => 'super_secret',
144+
145+
...
146+
]);
147+
```
148+
149+
The `secret` is a user-defined key that is required to execute any of the library's features.
140150
Best make it long, random and very unique!
141151

142152
For 84 random characters:
@@ -153,62 +163,103 @@ Enable admins? Add custom command paths? Set up logging?
153163

154164
**All no problem!**
155165

156-
Here is a list of available extra parameters:
157-
158-
| Parameter | Description |
159-
| --------- | ----------- |
160-
| validate_request | Only allow webhook access from valid Telegram API IPs. |
161-
| *bool* | *default is `true`* |
162-
| valid_ips | When using `validate_request`, also allow these IPs (single, CIDR, wildcard, range). |
163-
| *array* | *e.g.* `['1.2.3.4', '192.168.1.0/24', '10/8', '5.6.*', '1.1.1.1-2.2.2.2']` |
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. |
167-
| *string* | *e.g.* `'https://example.com/manager.php'` |
168-
| - certificate | Path to a self-signed certificate (if necessary). |
169-
| *string* | *e.g.* `__DIR__ . '/server.crt'` |
170-
| - max_connections | Maximum allowed simultaneous HTTPS connections to the webhook. |
171-
| *int* | *e.g.* `20` |
172-
| - allowed_updates | List the types of updates you want your bot to receive. |
173-
| *array* | *e.g.* `['message', 'edited_channel_post', 'callback_query']` |
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]` |
188-
| admins | An array of user ids that have admin access to your bot. |
189-
| *array* | *e.g.* `[12345]` |
190-
| mysql | Mysql credentials to connect a database (necessary for [`getUpdates`](#using-getupdates-method) method!). |
191-
| *array* | *e.g.* `['host' => '127.0.0.1', 'user' => 'root', 'password' => 'root', 'database' => 'telegram_bot']` |
192-
| paths | List of configurable paths. |
193-
| *array* | *Array keys listed below* |
194-
| - download | Custom download path. |
195-
| *string* | *e.g.* `__DIR__ . '/Download'` |
196-
| - upload | Custom upload path. |
197-
| *string* | *e.g.* `__DIR__ . '/Upload'` |
198-
| commands | All options that have to do with commands. |
199-
| *array* | *Array keys listed below* |
200-
| - paths | A list of custom commands paths. |
201-
| *array* | *e.g.* `[__DIR__ . '/CustomCommands']` |
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. |
207-
| *string* | *e.g.* `'botan_12345'` |
208-
| - options | Any extra options to pass to botan. |
209-
| *array* | *e.g.* `['timeout' => 3]` |
210-
| custom_input | Override the custom input of your bot (mostly for testing purposes!). |
211-
| *string* | *e.g.* `'{"some":"raw", "json":"update"}'` |
166+
Here is a complete list of all available extra parameters:
167+
168+
```php
169+
$bot = new BotManager([
170+
...
171+
172+
// (array) All options that have to do with the webhook.
173+
'webhook' => [
174+
// (string) URL to the manager PHP file used for setting up the webhook.
175+
'url' => 'https://example.com/manager.php',
176+
// (string) Path to a self-signed certificate (if necessary).
177+
'certificate' => __DIR__ . '/server.crt',
178+
// (int) Maximum allowed simultaneous HTTPS connections to the webhook.
179+
'max_connections' => 20,
180+
// (array) List the types of updates you want your bot to receive.
181+
'allowed_updates' => ['message', 'edited_channel_post', 'callback_query'],
182+
],
183+
184+
// (bool) Only allow webhook access from valid Telegram API IPs.
185+
'validate_request' => true,
186+
// (array) When using `validate_request`, also allow these IPs.
187+
'valid_ips' => [
188+
'1.2.3.4', // single
189+
'192.168.1.0/24', // CIDR
190+
'10/8', // CIDR (short)
191+
'5.6.*', // wildcard
192+
'1.1.1.1-2.2.2.2', // range
193+
],
194+
195+
// (array) Paths where the log files should be put.
196+
'logging' => [
197+
// (string) Log file for all incoming update requests.
198+
'update' => __DIR__ . '/php-telegram-bot-update.log',
199+
// (string) Log file for debug purposes.
200+
'debug' => __DIR__ . '/php-telegram-bot-debug.log',
201+
// (string) Log file for all errors.
202+
'error' => __DIR__ . '/php-telegram-bot-error.log',
203+
],
204+
205+
// (array) All options that have to do with the limiter.
206+
'limiter' => [
207+
// (bool) Enable or disable the limiter functionality.
208+
'enabled' => true,
209+
// (array) Any extra options to pass to the limiter.
210+
'options' => [
211+
// (float) Interval between request handles.
212+
'interval' => 0.5,
213+
],
214+
],
215+
216+
// (array) An array of user ids that have admin access to your bot (must be integers).
217+
'admins' => [12345],
218+
219+
// (array) Mysql credentials to connect a database (necessary for [`getUpdates`](#using-getupdates-method) method!).
220+
'mysql' => [
221+
'host' => '127.0.0.1',
222+
'user' => 'root',
223+
'password' => 'root',
224+
'database' => 'telegram_bot',
225+
],
226+
227+
// (array) List of configurable paths.
228+
'paths' => [
229+
// (string) Custom download path.
230+
'download' => __DIR__ . '/Download',
231+
// (string) Custom upload path.
232+
'upload' => __DIR__ . '/Upload',
233+
],
234+
235+
// (array) All options that have to do with commands.
236+
'commands' => [
237+
// (array) A list of custom commands paths.
238+
'paths' => [
239+
__DIR__ . '/CustomCommands',
240+
],
241+
// (array) A list of all custom command configs.
242+
'configs' => [
243+
'sendtochannel' => ['your_channel' => '@my_channel'],
244+
'weather' => ['owm_api_key' => 'owm_api_key_12345'],
245+
],
246+
],
247+
248+
// (array) All options that have to do with botan.
249+
'botan' => [
250+
// (string) The Botan.io token to be used for analytics.
251+
'token' => 'botan_12345',
252+
// (array) Any extra options to pass to botan.
253+
'options' => [
254+
// (float) Custom timeout for requests.
255+
'timeout' => 3,
256+
],
257+
],
258+
259+
// (string) Override the custom input of your bot (mostly for testing purposes!).
260+
'custom_input' => '{"some":"raw", "json":"update"}',
261+
]);
262+
```
212263

213264
### Using getUpdates method
214265

0 commit comments

Comments
 (0)