@@ -40,18 +40,20 @@ and then run `composer update`
4040
4141What use would this library be if you couldn't perform any actions?!
4242
43- There are 4 parameters available to get things rolling:
43+ There are a few parameters available to get things rolling:
4444
4545| Parameter | Description |
4646| --------- | ----------- |
4747| s | ** s** ecret: This is a special secret value defined in the main ` manager.php ` file. |
4848| | This parameter is required to call the script via browser! |
49- | a | ** a** ction: The actual action to perform. (handle (default), set, unset, reset) |
50- | | ** handle** executes the ` getUpdates ` method; ** set** / ** unset** / ** reset** the Webhook . |
49+ | a | ** a** ction: The actual action to perform. (handle (default), cron, set, unset, reset) |
50+ | | ** handle** executes the ` getUpdates ` method; ** cron ** executes cron commands; ** set** / ** unset** / ** reset** the webhook . |
5151| l | ** l** oop: Number of seconds to loop the script for (used for getUpdates method). |
5252| | This would be used mainly via CLI, to continually get updates for a certain period. |
53- | i | ** i** nterval: Number of seconds to wait between getUpdates requests (used for getUpdates method, default: 2). |
53+ | i | ** i** nterval: Number of seconds to wait between getUpdates requests (used for getUpdates method, default is 2). |
5454| | This would be used mainly via CLI, to continually get updates for a certain period, every ** i** seconds. |
55+ | g | ** g** roup: Commands group for cron (only used together with ` cron ` action, default group is ` default ` ). |
56+ | | Define which group of commands to execute via cron. Can be a comma separated list of groups. |
5557
5658#### via browser
5759
@@ -74,6 +76,12 @@ Handle updates once:
7476Handle updates for 30 seconds, fetching every 5 seconds:
7577- ` http://example.com/manager.php?s=super_secret&l=30&i=5 `
7678
79+ ** cron**
80+
81+ Execute commands via cron:
82+ - ` http://example.com/manager.php?s=super_secret&a=cron&g=maintenance ` or multiple groups
83+ - ` http://example.com/manager.php?s=super_secret&a=cron&g=maintenance,cleanup `
84+
7785#### via CLI
7886
7987When using CLI, the secret is not necessary (since it could just be read from the file itself).
@@ -97,12 +105,18 @@ Handle updates once:
97105Handle updates for 30 seconds, fetching every 5 seconds:
98106- ` $ php manager.php l=30 i=5 `
99107
108+ ** cron**
109+
110+ Execute commands via cron:
111+ - ` $ php manager.php a=cron g=maintenance ` or multiple groups
112+ - ` $ php manager.php a=cron g=maintenance,cleanup `
113+
100114### Create the manager PHP file
101115
102116You can name this file whatever you like, it just has to be somewhere inside your PHP project (preferably in the root folder to make things easier).
103117(Let's assume our file is called ` manager.php ` )
104118
105- Let's start off with a simple example that uses the Webhook method:
119+ Let's start off with a simple example that uses the webhook method:
106120``` php
107121<?php
108122
@@ -256,6 +270,24 @@ $bot = new BotManager([
256270 ],
257271 ],
258272
273+ // (array) All options that have to do with cron.
274+ 'cron' => [
275+ // (array) List of groups that contain the commands to execute.
276+ 'groups' => [
277+ // Each group has a name and array of commands.
278+ // When no group is defined, the default group gets executed.
279+ 'default' => [
280+ '/default_cron_command',
281+ ],
282+ 'maintenance' => [
283+ '/db_cleanup',
284+ '/db_repair',
285+ '/log_rotate',
286+ '/message_admins Maintenance completed',
287+ ],
288+ ],
289+ ],
290+
259291 // (string) Override the custom input of your bot (mostly for testing purposes!).
260292 'custom_input' => '{"some":"raw", "json":"update"}',
261293]);
0 commit comments