-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Organise to module * Use future annotations * Update license, readme, add mypy workflow * Update inits & setups for extensions. Format to line-length 100 * Fix mypy problems
- Loading branch information
1 parent
a162a56
commit 4bee20c
Showing
26 changed files
with
1,125 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SECRET="BlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: MyPy | ||
on: [push, pull_request] | ||
jobs: | ||
mypy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v3 | ||
with: | ||
python-version: 3.12.4 | ||
- uses: tsuyoshicho/[email protected] | ||
with: | ||
github_token: ${{ secrets.github_token }} | ||
# Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review]. | ||
reporter: github-pr-review | ||
# Change reporter level if you need. | ||
# GitHub Status Check won't become failure with warning. | ||
level: warning | ||
# Change the current directory to run mypy command. | ||
# mypy command reads setup.cfg or other settings file in this path. | ||
workdir: . | ||
|
||
setup_command: pip install -r requirements.txt | ||
setup_method: install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
__pycache__ | ||
*.tmp | ||
*.json | ||
.env | ||
|
||
.conda | ||
.venv | ||
|
||
.vscode | ||
.*_cache | ||
|
||
servers | ||
universe.pkl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
# HC-TCG Bot | ||
This is a discord bot designed for the hermitcraft tcg online server. It has commands that can be used for many things such as deck viewing, card information, admin commands for http://hc-tcg.fly.dev and more. | ||
The HC-TCG Bot is a bot for [hc-tcg online](https://hc-tcg.online). It interfaces with the api and has commands for the official hc-tcg online server. | ||
|
||
## Features | ||
- Card and deck information | ||
- Deck of the day competitions | ||
- Bug report management | ||
- Game creation and counting | ||
|
||
## Running | ||
To install dependencies, run `pip install -r requirements.txt` | ||
Optionally, also install tqdm using `pip install tqdm` to see progress bars when updating data | ||
Rename .env.example to .env and enter your discord bot key, then create a servers directory. The servers directory contains python files which define a single server object. | ||
|
||
It is recommended to run in a virtual environment, such as anaconda or venv. | ||
To install dependencies directly, run `pip install -r requirements.txt` | ||
|
||
I recommend first running [update_data.py](/update_data.py) to create a static universe. This will allow the bot to start quickly. To start the actual bot run [main.py](/main.py) | ||
Optionally, also install tqdm using `pip install tqdm` to see a progress bar when loading card data. | ||
|
||
## Formatting | ||
For formatting I use ruff, you can access the configuration in ruff.toml | ||
## Formatting and code style | ||
We use ruff for formatting and linting, and mypy for type checking. | ||
``` | ||
ruff format | ||
ruff check | ||
mypy -p bot | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""HC-TCG online bot.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Load environment config.""" | ||
|
||
from __future__ import annotations | ||
|
||
import os | ||
|
||
import dotenv | ||
|
||
|
||
class Config: | ||
"""Load environement variables as class.""" | ||
|
||
def __init__(self: Config) -> None: | ||
"""Load environement variables as class.""" | ||
dotenv.load_dotenv() | ||
|
||
env = os.environ | ||
|
||
self.SECRET: str = env.get("DISCORD_SECRET") or "" | ||
|
||
|
||
CONFIG = Config() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Bot extensions.""" |
Oops, something went wrong.