PROJECT IS DEPRECATED; SEE NEW VERSION HERE
Automatically detects new posts made on Reddit that match the specified queries and are in the specified subreddits, and sends them to Discord.
This bot primarily uses the Discord API (through discord.js) and the Reddit API (through snoowrap), in conjuction with a MongoDB for the backend (through mongoose). Here is a pseudocode outline of how the bot works:
- On login, initialize commands to Discord API and begin infinite timer
- Every 30 seconds
- For each Discord server Bot is in
- Search for the specified query in the specified subreddit in the past hour for all search entries attributed to the given server
- Check database if the query has been searched for, and from the current server.
- If yes, do nothing (if the database has the entry, it means it has been searched for from the current server already)
- If no, send the query to Discord, and send the query to the database with an expiration date of one hour
- Check database if the query has been searched for, and from the current server.
- Search for the specified query in the specified subreddit in the past hour for all search entries attributed to the given server
- For each Discord server Bot is in
- Constantly listen for commands/events
- If user runs comamand (
/ping
or/addchannel
or/removechannel
or/addquery [query] [subreddit]
or/removequery [query] [subreddit]
), respond appropriately - If Bot is added to new server, add the corresponding server info to the database
- If Bot is removed from a server, remove the corresponding server info from the database
- If user runs comamand (
/ping
: Replies with pong!/addchannel
: Allows the bot to post in the channel in which the command was sent./removechannel
: Revokes the bot's access to post in the channel in which the command was sent./addquery [query] [subreddit]
: Tells the bot to search for the specified query in the specified subreddit, if such an entry does not already exist. (Subreddit is last space separated keyword provided; defaults to "all" if only one space separated keyword provided.)/removequery [query] [subreddit]
: Tells the bot to stop searching for the specified query in the specified subreddit, if such an entry does already exist. (Subreddit is last space separated keyword provided; defaults to "all" if only one space separated keyword provided.)
No longer avaiable due to project deprecation. (See new updated version, as listed above, for a new working version.)
See here for instructions on how to self-host this bot.
Add compound indexing to reduce time complexity of database search fromO(n)
toO(1)
Add manual start/stop (requires multithreading)
See new version, as listed above, for new updates (including these fixes)