Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Containerize mk2 #117

Merged
merged 6 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions CONTRIBUTING.md

This file was deleted.

23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.10-slim

# add user and drop root permissions
ENV USER=cryptogull
RUN useradd -ms /bin/bash "${USER}"
USER ${USER}
WORKDIR /home/${USER}

# install source code
COPY --chown=${USER}:${USER} bot ./bot
COPY --chown=${USER}:${USER} pyproject.toml ./
COPY --chown=${USER}:${USER} poetry.lock ./

# required for 'poetry' command to execute when installed as user:
ENV PATH=${PATH}:/home/${USER}/.local/bin

# install dependencies
RUN pip install --disable-pip-version-check --user poetry && \
poetry install --no-dev

ENV PYTHONUNBUFFERED=True
HEALTHCHECK NONE
CMD ["poetry", "run", "python", "-m", "bot"]
64 changes: 55 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,62 @@
# cryptogull
A Discord bot for the [Caves of Qud discord](https://discordapp.com/invite/cavesofqud) (invite link).
A Discord bot for the [Caves of Qud
discord](https://discordapp.com/invite/cavesofqud) (invite link).

Features:
* Decode Caves of Qud character build codes into formatted character sheets
* Perform title and fulltext searches on the [official Caves of Qud wiki](https://wiki.cavesofqud.com/)
* Render tiles from the game and send them to Discord as attachments, with optional recoloring previews for modders
* Perform title and fulltext searches on the [official Caves of Qud
wiki](https://wiki.cavesofqud.com/)
* Render tiles from the game and send them to Discord as attachments, with
optional recoloring previews for modders

Cryptogull depends on another Trash Monks project, the [hagadias](https://github.com/TrashMonks/hagadias) library, to
read and interpret the game files.
Cryptogull depends on another Trash Monks project, the
[hagadias](https://github.com/TrashMonks/hagadias) library, to read the game
files.

## Contributing
See `CONTRIBUTING.md`.
Contributions from the community in the form of issues or pull requests are
welcome. This project uses the Code of Conduct available from that Discord
server, in the `#code-of-conduct` channel.

## License
Cryptogull is licensed under the terms of the GNU Affero General Public License Version 3. See the file LICENSE for details.
## How to use
1. Clone this repository. You need Docker installed.
2. Create a `config.yml` in your project directory from the provided
`config.example.yml`.
3. Log in to the [Discord Developer
Portal](https://discordapp.com/developers/applications/) and create a new
application. The name of the application is not your bot's username.
4. Skip directly to the "Bot" tab of the application you created. Set the icon
and username here. These can be changed later. Click the button to reveal the
bot token. Copy this token into the `Discord token:` field in `config.yml`.
5. Turn on the "Server Members Intent" slider in the Bot tab.
6. If you don't have a private Discord server to test in, make one.
7. Grab the 'Application ID' from the 'General Information' tab of the Discord
application you created (different from your bot token!)
8. Grab the permissions number you need from the 'Bot' tab of the Discord
application you created. This should be 100352, which is the number created
by checking the 'Send Messages', 'Attach Files', and 'Read Message History'
checkboxes. If you're developing features that use higher permissions, check
those permission boxes as well and use the permissions number created by
doing that.
9. Craft a URL to join your bot to your server. The format is
`https://discordapp.com/api/oauth2/authorize?client_id=xxxxxxxxxxxxxxxxxx&scope=bot&permissions=y`
where the `x`s are the number from **step 7**, and `y` is the number from
**step 8**.
10. Go to the URL and accept any prompts.
11. Run the bot through Docker using the commands below.

## Example docker commands
To build and run the bot:

```bash
docker build . -t cryptogull:latest
docker run -it --rm -v ./config.yml:/home/cryptogull/config.yml -v "C:\Steam\steamapps\common\Caves of Qud":"/home/cryptogull/Caves of Qud" -v ./Textures:/home/cryptogull/Textures --name cryptogull cryptogull:latest
```

This attaches the config file, game data folder, and tile art folder as volumes
inside the running container.

## Tile support
Tile support requires a full extract of the game Textures directory. To get an
up-to-date copy of the game textures, install the
[brinedump](https://github.com/TrashMonks/brinedump) mod and use the
`brinedump:textures` wish.
Loading