This is a discord bot written in Python which searches a text file using RegEx to find a quote and output the line containing the quote as well as the next line in an embed message.
The bot currenly supports searching feature for the following fanfiction-
- Harry Potter and the Prince of Slytherin by The Sinister Man
- Black Luminary by YakAge
- Harry Potter and the Ashes of Chaos By ACI100
The bot's command prefix is q
The bot has the following commands:
- qf: To search a quote
- qfk: To search a quote using keywords
- qhelp: To show the help command
The following is an example on how the bot works in realtime-
- Install Python >=3.8.5
- Create a python virtual environment in which you will be installing all the dependencies and activate it before installing the dependencies.
- Install the dependencies using
pip install -r requirements_dev.txt
-
Create a new directory called
Quote Finder
in you system. You will be forking and cloning the Quote-Finder & Quote-Finder-Data repository. -
Quote-Finder contains the source code for the bot.
-
Quote-Finder-Data contains the data files and is added as a submodule to the Quote-Finder repositories.
-
Fork the Quote-Finder repository and clone the fork in the
Quote Finder
directory usinggit clone --recurse-submodules <URL>
since the repository contains a submodule. -
Create a new branch for your development. Do not add new features to the
main
branch.
-
Since all the data files are stored in a separate Github repository called Quote-Finder-Data, you will need fork & clone it in the
Quote Finder
directory to add or updates data files. -
Add or update any files you need to and then push to your fork. Then make a PR to the Upstream
-
You will need to pull the submodule once your changes are merged in the Quote-Finder-Data repository.
-
In your
Quote-Finder
directory, you can simplycd data/
andgit pull
, as you normally do for repositories since the submodule is also a git repository. -
Alternatively, you can also use
git submodule foreach git pull origin main
to pull the changes. This is the recommended way.
Note: This pulls from the Upstream Quote-Finder-Data repository as configured in the .gitmodules
file. During development, you can change the url
of the submodule to your fork or you can directly copy the files to your local /data
directory (recommended).
-
Create a
.env
file which should contain theDISCORD_TOKEN
for your testing bot as shown in the.env.ex
file. -
Create a testing bot from the Discord Developer Portal and copy the bot token to the
.env
file. -
Run the bot using
python main.py
in the root directory. -
To add support for other fanfictions, check the
scripts/
directory to know how to add the necessary data files.