Simple PHP script to automate the sending Rocketchat messages
Go to file
loviuz dd9ef0f80c
Updated README
2021-05-29 01:15:20 +02:00
.gitignore First draft 2021-05-24 19:26:52 +02:00
LICENSE Initial commit 2021-05-24 19:08:06 +02:00
README.md Updated README 2021-05-29 01:15:20 +02:00
composer.json First draft 2021-05-24 19:26:52 +02:00
config.example.php Completing first version 2021-05-29 00:52:00 +02:00
rc-automator.php Completing first version 2021-05-29 00:52:00 +02:00

README.md

Rocketchat auto-messages

Simple PHP scripts to automation of sending Rocketchat messages.

How to install

php composer.phar install

How to configure

Copy config.example.php to config.inc.php. The first index is the user or the name of the message you want to schedule. Next you have to specify on which year, month, day, hour, minute or day of week you want to send the message:

$users = [
    'user1' => [
        'webhook' => 'https://rocketchat.yourserver.com/hooks/123456abcdef',
        'year'      => '*',
        'month'     => '*',
        'day'       => '*',
        'hour'      => '9',
        'minute'    => '0',
        'daysOfWeek'=> '1',
        'message' => [
            "text" => "Wake up!"
        ]
    ]
];

Finally, in °°message°° array, you can specify the message to send with the syntax provided by Rocket Chat.

In this example the text "Wake up!" will be sent only on monday (day of the week number 1) at minute 0 and hour 9.

How to run

php rc-automator.php

If there is a message to send, the output will be:

[*] Checking messages for user1... sending message... sent!

Otherwise the output will be:

[*] Checking messages for user1... no message to send.

Cron

You should configure this script in crontab like this:

  0/5 *  *  *  * apache  cd /path/of/the/script && php rc-automator.php

If the frequency of the messages is not under 5 minutes it is recommendend to set the execution every 5 minutes.