Compare commits
No commits in common. "ad70870d8e7ccacbeca84e620891b78b4c883af7" and "512b3b05d25ba79a50fc5126e27cb7aee738f299" have entirely different histories.
ad70870d8e
...
512b3b05d2
@ -1,7 +1,7 @@
|
||||
# Copyright 2022 - c0de <c0de@c0de.dev>
|
||||
# Licensed under the MIT License (https://opensource.org/licenses/MIT)
|
||||
|
||||
# Build with: docker build -t baseballbot:<version> .
|
||||
# Build with: docker build -t ghotballbot:<version> .
|
||||
# Run with: docker run -it
|
||||
|
||||
FROM python:3.10-alpine3.16 AS build
|
||||
@ -13,6 +13,6 @@ COPY . .
|
||||
FROM build AS run
|
||||
|
||||
ENV discord_token ""
|
||||
ENV database_path "/tmp/baseball.db"
|
||||
ENV database_path "/tmp/ghostball.db"
|
||||
|
||||
CMD ["python", "/app/main.py"]
|
||||
|
@ -22,7 +22,7 @@ from peewee import (
|
||||
)
|
||||
|
||||
# User can provide path to database, or it will be put next to main.py
|
||||
DATABASE = os.environ.get("database_path", os.getcwd() + "/baseball.db")
|
||||
DATABASE = os.environ.get("database_path", os.getcwd() + "/ghostball.db")
|
||||
database = SqliteDatabase(DATABASE, pragmas={"foreign_keys": 1})
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
# pylint: disable=wrong-import-position
|
||||
|
||||
"""
|
||||
A discord bot that hosts Baseball/Braveball.
|
||||
A discord bot that hosts Ghostball/Braveball.
|
||||
|
||||
A discord game where players guess the pitch speed
|
||||
from a fantasy baseball pitcher, and whoever is
|
||||
@ -21,7 +21,7 @@ sys.path.append("..")
|
||||
from game.manager import GameManager
|
||||
|
||||
|
||||
class BaseBallClient(discord.Client):
|
||||
class GhostBallClient(discord.Client):
|
||||
"""
|
||||
Implementation of a Discord client that will monitor
|
||||
a channel for messages, and if it recieves a message
|
||||
|
4
main.py
4
main.py
@ -7,7 +7,7 @@
|
||||
import os
|
||||
|
||||
from discord import Intents
|
||||
from discord_client.client import BaseBallClient
|
||||
from discord_client.client import GhostBallClient
|
||||
from database.models import DATABASE, database, create_models
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -17,5 +17,5 @@ if __name__ == "__main__":
|
||||
create_models()
|
||||
database.close()
|
||||
|
||||
client = BaseBallClient(intents=Intents.all())
|
||||
client = GhostBallClient(intents=Intents.all())
|
||||
client.run(os.environ.get("discord_token"))
|
||||
|
88
readme.md
88
readme.md
@ -1,80 +1,36 @@
|
||||
# Discord Baseball Bot
|
||||
# Discord Ghost Ball Bot
|
||||
|
||||
A bot that will listen on a discord channel, accpeting commands.
|
||||
A bot that will listen on a discord channel, accpeting commands.
|
||||
The main commands are `!start`, `!guess [int]` and `!resolve [int]`.
|
||||
|
||||
The main commands are `!braveball`, `!guess [int]` and `!resolve [int]`
|
||||
Use the `!help` command for more information
|
||||
The integer will be between 1 and 1000, and the person with the closest guess will win points.
|
||||
|
||||
The point scale is:
|
||||
|
||||
* 0-25 - 100 pts
|
||||
* 26-50 - 75 pts
|
||||
* 51-75 - 50 pts
|
||||
* 76-100 - 25 pts
|
||||
|
||||
There should also be a running total for each player that can be checked with a command.
|
||||
|
||||
## Requirements
|
||||
|
||||
1. You will need a discord bot and an auth token
|
||||
1. You will need access to a server that runs Docker
|
||||
* For development, docker is optional. See Development section of Usage below
|
||||
|
||||
## Points
|
||||
|
||||
Points are determined by the difference, which comes from this formula:
|
||||
|
||||
```python
|
||||
difference = abs(guess - pitch_value)
|
||||
|
||||
if difference > 500:
|
||||
difference = 1000 - difference
|
||||
```
|
||||
|
||||
The point scale is a range based on the difference
|
||||
|
||||
| minimum | maximum | points |
|
||||
|-----------------|-----------------|--------|
|
||||
| (no difference) | (no difference) | 15 |
|
||||
| 1 | 20 | 8 |
|
||||
| 21 | 50 | 5 |
|
||||
| 51 | 100 | 3 |
|
||||
| 101 | 150 | 2 |
|
||||
| 151 | 200 | 1 |
|
||||
| 200 | 494 | 0 |
|
||||
| 495 | 500 | -5 |
|
||||
|
||||
Points are added to a running total for each player at the end of each round.
|
||||
|
||||
## Usage
|
||||
|
||||
If you are using docker:
|
||||
|
||||
1. You need to determine which version of the bot to use
|
||||
* If you are using a raspberry pi, you want `archarm64`
|
||||
* Otherwise, you most likely want `archx64`
|
||||
|
||||
### Production with docker
|
||||
|
||||
This docker command is the minimum required to run the bot:
|
||||
|
||||
`docker run -d -e discord_token="<discord token> c0defox/baseballbot:<version>"`
|
||||
|
||||
_Note: The above will not persist the database through restarts_
|
||||
|
||||
If you want to keep the database, use the following command:
|
||||
|
||||
`docker run -d -v database:/database -e database_path="/database/baseball.db" -e discord_token="<discord token>" c0defox/baseballbot:<version>`
|
||||
|
||||
### Development with docker
|
||||
|
||||
1. Modify the source code
|
||||
1. Run `docker build -t baseballbot:<tag> .`
|
||||
1. Run the same docker commands you would in production
|
||||
|
||||
_note: You will probably want to purge your builds after a while, as they will eventually take up space_
|
||||
|
||||
### Development without docker
|
||||
You will need a discord bot already set up and supply an auth token.
|
||||
|
||||
Python requirements can be installed with `pipenv install` (install pipenv with `pip3 install pipenv`)
|
||||
|
||||
## Usage
|
||||
|
||||
All of the new bot code is in the [GhostBallBot](./GhostBallBot/) folder. This documentation is for the new code.
|
||||
|
||||
The original code is in [src](./src/). Feel free to try to get this working.
|
||||
|
||||
1. Install the python requirements
|
||||
1. Add discord token to run.sh
|
||||
1. Modify the source code
|
||||
1. Start run.sh in the terminal (restart as you make code changes)
|
||||
1. Execute run.sh
|
||||
1. Bot should then connect to discord and start responding to commands defined in game.py
|
||||
|
||||
If you modify the source code, you should also run `lint.sh`. This will warn you of linting problems that you can choose to fix, as well as format all of the code to the same standard automatically (usually this will resolve linting warnings)
|
||||
|
||||
## Roadmap
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user