Reddit Notifications

A program to send Reddit posts from specific subreddits to a Telegram channel

Interacting with Reddit

Unfortunately the Reddit API doesn't offer any event driven functions, they also have a very tight rate limit which caused the first problem:

Scaling the multiple subreddits

At first this seemed easy, iterate through each subreddit and fetch the newsest posts. However, the client wanted it to be as close to real time as possible which wasn't possible with this implementation (Reddit have a fairly strict rate limit on their API). Fortunately, I found a little known feature that allows you to specify a search space larger than one subreddit, essentially combining multiple subreddits, combining this with a simple method to make sure that if two posts happened at the same time the program wouldn't only fetch one and we're away.

Communicating with Telegram

Telegram have a fantastic API that allows you to create bot users and easily interact with the service. Although it was more confusing than I expected to create a channel that the bot could send messages to. After that initial speed bump was done it was smooth sailing so to speak, implement some commands to let the client select the subreddits to watch as well as reset the bot if it stops working and it was, for all intents and purposes, completed.

After having the program run for an extended period of time (roughly 2 months) the client informed me that it was no longer working… A freelancers worst nightmare, I checked the logs and it seemed to be producing 404 errors which seemed odd. After much debugging I realised I had created an error condition where the program got stuck in a loop instead of resetting on error; since fixing this it has been running flawlessly since.


This project was a lot of fun, requiring the solution to a lot of problems I did not expect to deal with, overall I'm very happy with the outcome. However there is definitely some code that could be cleaned up to make it more maintable for the future.