This is a collection of scripts that use the telegram api to create helpful bots. These bots are best triggered using cronjobs to send customized reminders or polls! Feel free to use the scripts straight away or modify them to suit your needs.
Attention: If you fork this directory, make sure to never push any file containing your token or id!
- Clone this repo to your desired location.
- Obtain your bot token from telegram
- Add your bot to a desired chat
- Get the chat id as follows:
- Open a new window in privacy mode in your prefered browser. This ensures that your token is not stored in the browser history.
- Copy this URL into your opened window:
https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates
- Replace
YOUR_BOT_TOKEN
with your actual token and press Enter - In the output find the
chat
key and look for anid
field just below. This will only work, once you have added your bot to a chat.
- Open a new window in privacy mode in your prefered browser. This ensures that your token is not stored in the browser history.
- Copy your bots token and the chat id into the
config.txt
- Run any of the top level scripts from the command line
- To repeatedly run script, you can setup a cronjob
- On ubuntu, type:
crontab -e
- Add a new line in the following format: crontime command path_to_script >> path_of_logfile 2>&1
- For example:
20 16 * * 02 /bin/bash ~/dobby/send_garbage_reminder.bash >> ~/dobby/garbage_poll.log 2>&1
- This would run the script on every Tuesday at 16:20. Adjust the time definition as needed. Get some help here.
- Adjust the path to the script and log file
- Save and exit the file
- On ubuntu, type:
name | type | annotation |
---|---|---|
send_garbage_reminder.bash | file | sends a weekly poll to remind taking out the garbage |
config.txt | file | store your credentials |
modules | directory | helper scripts |
data | directory | stores text files with strings or links for random response customizations |