Short little script to remind me on the first of every month to post in a channel. Uses crontab (0 0 1 * *) to call the script
The project dependencies are listed in a Pipfile. Use pipenv to trigger python virtual environment:
cd reminder-bot
pipenv install
Pipenv uses virtualenv to create a python environment with all the dependencies listed in the Pipfile. Before running the reminder.py script, you must first activate the environment:
pipenv shell
If you wish to deactivate the environment use the command
exit
A /config/config.json file need to be created in the same directory with reminderstat.py
Below is an example of the config.json file.
{ "token":"your-token", "channel":"your-channel-id", "message":"your-message" }
The following arguments can be passed to the script
Short | Long | Type | Description |
---|---|---|---|
-c | --config | string | config file path, default is set to "./config/config.json" |
We can use cron to automatically run the script periodically in order to keep it up-to-date. You will need either a macOS computer or Linux server to use cron.
-
Set up config file with specified template in
Config file
section -
Run
crontab -e
to open the cron editor -
Use the following format to create a line for your cron
* * * * * command to be executed - - - - - | | | | | | | | | ----- Day of week (0 - 7) (Sunday=0 or 7) | | | ------- Month (1 - 12) | | --------- Day of month (1 - 31) | ----------- Hour (0 - 23) ------------- Minute (0 - 59)
For example, to run the script with default config file at 9 AM everyday, insert the following line
0 9 * * * cd /home/tduong/remider-bot && /usr/local/bin/pipenv run python reminder.py
Note: run
which pipenv
to identify your pipenv path. Mine is "/usr/local/bin/pipenv"To trigger the script with
your-config.json
at 9 AM everyday, run the below0 9 * * * cd /home/tduong/remider-bot && /usr/local/bin/pipenv run python reminder.py -c ./config/your-config.json
See projects tab