-
Notifications
You must be signed in to change notification settings - Fork 8
Setting up the bot
Spectre uses the following dependencies for "normal" use:
discord.py
python-dotenv
Spectre uses the following dependencies for the update file:
gitpython
Spectre uses the following dependencies for the price
command:
bs4
lxml
Spectre uses the following dependencies for the "image reading" functionality:
pytesseract
Tesseract binaries
If you don't want to set one of the non required ones up, you can simply not install them and remove/comment out the relevant files (making sure to remove them in the main Spectre.py
file to not encounter issues).
You can install these at a "controlled" version with Poetry by first installing poetry (curl -sSL https://install.python-poetry.org | python3 -
in a terminal), using cd
to get into the Spectre
directory, then running poetry install
Or you can install them by using pip install discord.py python-dotenv gitpython bs4 lxml
in a terminal.
If your pr adds a dependency, please add it to the poetry list by using cd
to get into the Spectre
directory, then run poetry add DEPENDENCY_NAME_HERE
.
Spectre relies on using a file called .env
with the library python-dotenv
to load sensitive information.
It requires at the very least having a Discord bot token, with an option for a GitHub access token for using the GitHub api (only used for fetching Northstar version as of writing)
It should look like:
TOKEN = "PLACEYOURDISCORDBOTTOKENHERE"
GH_ACCESS_TOKEN = "PLACEYOURGITHUBTOKENHERE"
Again noting you don't need the GitHub token, and making sure to keep the quotes when pasting in the tokens
Inside config.json
in the bots files, you should see something like this:
{
"admin": 502519988423229460,
"prefix": "$",
"reportchannel": 1137078947180449822,
"playtesterchannel": 936678773150081055,
"playtesterrole": 1137080594279432242,
"thunderstorechannel": 939573786355859498,
"dmlogreports": false,
"DataFiles": [
{
"name": "noreplylist",
"path": "data/noreplyusers.json"
},
...
]
}
To put it simply:
"admin" refers to the user id of the person you want to be able to use the "big" commands
"prefix" is the text based fall back prefix instead of the slash command
The other lines are specific pieces of information for the bot to use and be changed easily by the owner.
The DataFiles
array stores information for a "code-name" and path to store json data. This data can be accessed by the bot, and used for commands (such as allowed channels and allowed users)
To use the JsonHandler in the final version of Spectre, first import it (this can be done easily in a cog by adding a single import- import util.JsonHandler
)
Once it's imported, it can be used like so:\
data = util.JsonHandler.load_json("json_name")
This will give you the data in (I think :P) a dict format. You can look at examples of how it's used in files such as AllowedUsers.py
.
Data can also be saved back to these json files. You can do it like so:
util.JsonHandler.save_json("json_name", data)
Note you only need to do this if you edit the data from the json.
You can freely add entries to the config.json
file. To retrieve them, use:
data = util.JsonHandler.load_data("data_name")
This will return the matching data from the config file (if found)
Spectre comes with a file called updateSpectre.py
. This file allows you to run python updateSpectre.py
, then choose if you want to
- Update Spectre (clone newest repo, move data files to it)
- Test a Spectre branch (mainly for me, but you can just input a Spectre branch url for testing and data files move to it automatically)
- Restore Spectre data (to be used in a Spectre branch from the
test
command, moves data from the current branch folder to the original Spectre folder)
(Note: As of the final version, this is obsolete and should be changed on a fork)
Running the file also runs you through these steps