A Reddit bot that translate a message when queried.
Why? I try to work on something every day. This is something I've wanted to do for a while so I decided to dedicate some hours of my weekend to it.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- Install Python.
- Clone this repository.
- Open a terminal window inside the folder the project is located and create a virtual environment:
$ py -m venv venv
. - Activate the virtual environment:
$ cd venv/Scripts/activate
. - Install
requirements.txt
:$ pip install -r requirements.txt
. - Open
praw.ini
and edit the values at the bottom. Having trouble figuring out what to write? Check this link. - Run
$ py app.py
.
Any user can use the following command syntax to summon this bot: @translate lang message
. If the message does not contain the right parameters (to make it short: if length of lang
> 2; if message
< 1; if lang
does not exist in the Yandex API), the bot will send a message to the user with clear instructions of how to use the bot.
The message containing the instructions.
To comply with bottiquette, I've added an option to (un)blacklist subreddits on the fly (and you can read about how that works here). This was a great opportunity to get some experience with databases.
If, however, the subreddit you summon the bot to isn't blacklisted; the language you provided is available in the Yandex API; and you provided a message with more than one character, the bot will reply to your comment in this fashion:
- PRAW — The Python Reddit API wrapper.
- Regex101 — Helped a lot with regular expressions. I had never worked with regular expressions and it took me 5 minutes to get the gist of it with the help of this tool.
- Requests-HTML — Used to scrape the list of moderators for the (un)blacklisting feature.
- Requests — Used to GET and POST data.
- Carlos Menezes — Initial work - c-mnzs