This worker fetches prayer times 🕌 from a remote API and posts a message to Slack when it's prayer time and when the prayer time is about to end so you're almost sure in sha Allah that you're not missing any prayers ✌️.
This is how it looks like 🕶️
You can run this script either locally or using docker
.
- Install
requests
dependency by runningpip install requests pytz iso3166
- Setup an Incoming Webhooks in Slack's Integration: https://my.slack.com/services/new/incoming-webhook.
- Get the Webhook URL e.g.
https://hooks.slack.com/services/example
. - Put the Webhook URL into the
config.json
. - Modify the location variables
CITY
andCOUNTRY
in the config file to match your location. - The script will use the location specific API e.g. URL = http://api.aladhan.com/v1/timingsByCity?city=mecca&country=Saudi Arabia&method=5 for Mecca, Saudi Arabia based on the variables you set above.
- OPTIONAL: Modify the Slack username (can be any name, you don't have to create the user beforehand) in
prayer_times_slack_bot.py
. - OPTIONAL: Modify the Slack channel name
SLACK_CHANNEL_NAME
inprayer_times_slack_bot.py
to post to a certain channel. - OPTIONAL: Modify the emoji name to be used as user's icon
the script is meant to be run as a background task, so it keeps scheduling tasks and doesn't exit on it's own.
Idea and setup steps credits go to Sholat-Prayer-Times-Slack by ainunnajib
Deidicated to Rubikal LLC. 🏠, I developed this script when I was there and they welcomed the idea once I asked to deploy it on their servers, and they didn't mind that I own the script and release as opensource code.
You can deploy the script directly to a container using deploy.sh
and this will build and launch the container.
chmod u+x deploy.sh # Make the script runnable
./deploy.sh
The mentioned way of getting webhook URL is deprecated and might be removed in the future. Please watch this video if you face any issues obtaining your slack webhook URL.
You might want to run this as a task on your PC or using a server. I use DigitalOcean for my development server, check it out here (my reference link)