Skip to content
This repository has been archived by the owner on Dec 24, 2021. It is now read-only.
/ prequelmemes_bot Public archive

Repository for u/prequelmemes_bot. Apply OCR techniques to find quotes from familiar films and movies

License

Notifications You must be signed in to change notification settings

thecsw/prequelmemes_bot

Repository files navigation

u/prequelmemes_bot Documentation

Hello there!

Welcome to the source page of u/prequelmemes_bot! Nice to meet you. First of all, let me talk you through what the bot does and details later. If you want to help the bot, please go down to the TODO list and find your way to contribute! Thanks!

./doc/pic.png

Getting started

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.

Prerequisites

What you need is just basic installation of docker and its enabled state.

sudo apt-get update
sudo apt-get install docker docker-engine docker.io
sudo systemctl start docker
sudo systemctl enable docker

This will install docker on your machine and enable the docker daemon.

Installing and configuring

The only thing that needs to be done before execution is the config. The only thing that needs to be done before execution is the config profile. In the config profile you should fill your Reddit API details.

For that please follow the steps below

git clone https://github.com/thecsw/prequelmemes_bot.git
cd prequelmemes_bot
mv .env.example .env
nano .env

After filling out the details, save and exit. You’re done with installation.

Deployment

In order to deploy the bot, you should have configured the .env file. Now, we need to build the containers and set them running. Commands below will do the building and deployment. The build stage might take several minutes to download and install all the required dependencies. The time taken directly depends on your hardware. The maintenance details are in the next part.

NOTE You also should have configured docker, so you can run docker-compose and docker commands without sudo privileges. Read docker manuals or google how to add a user to docker group.

docker-compose build -t prequelmemes_bot
docker-compose up -d

That is everything. All the prequelmemes will be identified. Once and for all, the archives will never be incomplete.

Maintenance

Start the services

This will just start all services in detached mode.

docker-compose up -d

Stopping the services

Do not use the down command as it will wipe out created containers and images. This may cost you your database data. If you want to down the bot, backup it first. However, the command below will just stop active services and will keep the images and containers. After that, you can fire it up again.

docker-compose stop

Restarting the services

This command will restart all services.

docker-compose restart

Checking logs

To check how the bot is doing, use the command below to view an output from all active services.

docker-compose logs

Backing up the database

I wrote a little bash script that will copy the database contents and dump them into a file. You need to configure the backup.sh.example file first.

./backup.sh

Updating source code

The ./src folder on the host machine is volumed with ./src folder in the container for the service bot. There is no need for rebuilding if the source code has changed. The following command will update the source code and restart the services.

git pull && docker-compose restart

Source code

The code is heavily commented and all the important modules are being separated into different files. Looks pretty, dunno.

Built With

  1. Docker is the company driving the container movement and the only container platform provider to address every application across the hybrid cloud.
  2. praw is Python Reddit API Wrapper. This will be the main and only package to connect to Reddit’s API and extract desired data.
  3. python-opencv is used for image transformations and computer vision problems.
  4. pytesseract is a python wrapper for Google’s Tesseract-OCR.
  5. Pillow is the Python Imaging Library by Fredrik Lundh and Contributors.
  6. pysrt is a Python library used to edit or create SubRip files.

License

This project is licensed under the The GNU General Public License (see the LICENSE file for details), it explains everything pretty well.

Authors

  • Sagindyk Urazayev - Core Developer. Back-end. - thecsw
  • farhank3389 - Fixes - farhank3389

Todo list

This is going to be a short todo list. If you have the true loyalty and some free time, try to add/fix the following todo items or add your own with the issues tab or push.

[#C] Add a comment feature.

I don’t have an idea of what to do. I made some prototypes, don’t know. If the bot is going to answer to each comment, that is just a spam.

DONE:

[#A] Port the whole thing to docker.

I find it pretty practical to run the bot in an isolated container instead on a host machine. This whole thing may take a while…

[#A] Port the bot’s data to a server-based database.

SQLite is a good approach for some mobile applications and so on but it is bad if you have a lot of data and want to be somewhat professional. I might go with MySQL or PostgreSQL.

[#B] Get rid of tabulate.

This is a really bad logging approach, I need to get rid of the ASCII tables.

[#B] Make some general fixes to the code.

Add some little new features, replace old ones with new ones. Make a faster version. Just a general quality assurance.

[#A] Edit the mesage body text.

The message body text isn’t perfect. It can be more prequelmemed. So yeah, if somebody can do it, that would be awesome.

[#A] Port the code to python3.6+

Just port the whole code. I am not talking about just using python3 main.py instead of python main.py. I am talking about using the new python3+ features. Like better string formatting, like the print(f"{args}...").

[#A] Change tqdm for another approach

tqdm is throwing some strange annoying warnings. Will need a more manual way of counting things.