i hate instant notifications. i hate this bell which tells you to stop whatever thought you were having and check your phone. it may seem innocuous, except it's not. this is nothing less than pavlov dystopian shit, and one of the worst behavioral things to come out of the past decade.
i removed all notifications from my android apps, and i remove them again and again —every time i have to reboot my phone, actually, because the damn thing reactivates half of them by default. next step would be flashing a less awful OS on my phone. maybe next year, when mainstream apps will become too resource-hungry for my 7-year-old phone and i have nothing left to lose.
having said that. i don't want to be interrupted whenever one of the twitch streamers i follow goes live, but i still like to be informed when i find myself available. usually this coincides with my checking of telegram for kind words, sexy pics or refined shitpost from my terrorist friends.
introducing: LajujaBot, a telegram bot sending notifications when selected streamers go live.
i bothered to write a proper readme on the github repository so allow me to quote myself:
We make use of python-telegram-bot & webhooks via twitchAPI. Basically the twitchAPI library sets up a webhook which will make Twitch report go-live events to a public domain under your control. When the alert reaches your side (usually 30-60s after the streamer actually goes live), it triggers the bot into sending a message to every chat which subscribed to the related Twitch channel.
i checked for existing bots first, but either they were dead or they spoke russian, and it seemed easier to code a new bot than to learn russian. as a starting point, i cloned the repository of a broken bot called misterino, but i ended up eviscerating most of it. here are the main changes:
- offload the twitch authentication and webhook to
- offload all database operations to the storage features of
- streamline the user interface into something more concise and lively.
all in all, learning about the twitch API & the telegram bots and finding the right libraries and linking them together and designing the data schemas and writing a user interface and testing the whole thing was done in ~48 hours. i'm showing off in case someone would like to hire me (please).
on a more humble note, i was impressed and pleased by all the resources made available by twitch and telegram through their respective APIs. these are great open endeavors.
finally, i ought to mention that in order to prevent abuse on my small server, i put a safety check on the number of subscriptions each telegram user could seek, i.e. no more than one hundred of them. should someone want to deploy the bot on a more powerful server, it could be easily removed.