I wrote Keep your streak in the work week on The Human In The Machine today. My article is about how I built ChillBot, a Slack bot that messages me on the weekends to let me know if I’ve contributed on GitHub for seven consecutive days and to encourage me to take a break.
The message looks something like this:
How it works
- Fetch all my activity on GitHub through the Events API. (The API only retrieves up to 300 events, so if you’re a power user, the API may not retrieve enough data to decide if you have a streak or not.)
- Get every unique date when I did something on GitHub.
- Figure out how many days I’ve contributed on GitHub by looping through every day starting with yesterday through my decided streak (7 days). And if that day matches a day that I contributed on GitHub then mark it, if it doesn’t then break the loop.
- If my streak is greater or equal to the number of days I contributed, ping me on Slack.
Ironically, it took a little bit to break my streak as I was working on this bot on the weekend, but I am proud of any of my gray-square weekends.
You can check out the code on GitHub and learn how to automate the bot with Amazon Web Services with the steps I wrote up.