Skip to content

Commit

Permalink
Merge pull request #148 from DMcP89/release/v0.4.0-Beta
Browse files Browse the repository at this point in the history
Release/v0.4.0 beta
  • Loading branch information
DMcP89 authored Aug 24, 2024
2 parents 4389692 + 35c7512 commit f801f6f
Show file tree
Hide file tree
Showing 41 changed files with 1,710 additions and 998 deletions.
47 changes: 47 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Contributing to harambot

PRs are welcome provided they follow the guidelines and procedures below.

## Procedure
1. Open an issue/feature request to discuss the changes you want to make
2. Fork the repository
3. Create a new branch
4. Make your changes
5. Create tests for your changes
6. Run tests
7. Commit your changes
8. Push your changes
9. Create a pull request

## Guidelines
- Follow the GitHub Community Guidelines
- Be responsive and open to discussions and suggestions from the project maintainers and contributors
- Toxic behavior or bullying will not be tolerated

## Setting up development environment

### Prerequisites
- Python 3.8 or higher
- pyenv
- pyenv-virtualenv
- poetry

### Environment setup
Use the following commands to setup your local environment
```
git clone [your fork url]
cd harambot
pyenv virtual-env 3.8 harambot
pyenv local harambot
poerty install --with dev
precommit install
precommit autoupdate
precommit run --all-files
```

### Running tests
You can run the tests by running the following from the projects root directory
```
pytest
```
25 changes: 0 additions & 25 deletions .github/workflows/pytest.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: run-pytest

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install project
run: poetry install --no-interaction
#----------------------------------------------
# run test suite
#----------------------------------------------
- name: Run tests
run: |
source .venv/bin/activate
pytest --disable-warnings
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ oauth2.json
oauth.json

.vscode

.vim
secrets.json
guilds.json
# Ignore dynaconf secret files
Expand All @@ -18,3 +18,4 @@ answers.txt
.coverage

dist/
backups/
25 changes: 23 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ test:
@python -m pytest -v

run:
@pip install -r requirements.txt
@poetry install
@python ${MODULE}/bot.py

build-image-dev:
@echo "${BLUE}Building docker image.."
@echo "name: ${MODULE}"
@echo "tag: ${MODULE}:${TAG}${NC}\n"
@docker buildx debug build --no-cache -t ${MODULE}-dev:${TAG} -f ./docker/Dockerfile.dev .

build-image:
@echo "${BLUE}Building docker image.."
@echo "name: ${MODULE}"
@echo "tag: ${MODULE}:${TAG}${NC}\n"
@docker build --no-cache -t ${MODULE}:${TAG} .
@docker build --no-cache -t ${MODULE}:${TAG} -f ./docker/Dockerfile .

run-docker:
@echo "${BLUE}Running docker image.."
Expand All @@ -34,6 +40,21 @@ run-docker:
-e YAHOO_KEY=${YAHOO_KEY}\
-e YAHOO_SECRET=${YAHOO_SECRET}\
-e DATABASE_URL=${DATABASE_URL}\
-e HARAMBOT_KEY=${HARAMBOT_KEY}\
-e RUN_MIGRATIONS=${RUN_MIGRATIONS}\
-e PORT=10000\
--rm ${MODULE}:${TAG}

run-docker-dev:
@echo "${BLUE}Running docker image.."
@echo "name: ${MODULE}"
@echo "tag: ${MODULE}:${TAG}${NC}\n"
@docker run --rm --name ${MODULE}-dev\
-e DISCORD_TOKEN=${DISCORD_TOKEN}\
-e YAHOO_KEY=${YAHOO_KEY}\
-e YAHOO_SECRET=${YAHOO_SECRET}\
-e DATABASE_URL="sqlite:///dev.harambot.db"\
-e RUN_MIGRATIONS=${RUN_MIGRATIONS}\
-e HARAMBOT_KEY=${HARAMBOT_KEY}\
-e PORT=10000\
--cpu-period=50000 --cpu-quota=25000 --memory=512m ${MODULE}-dev:${TAG}
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

38 changes: 16 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
![harambot-banner](./assests/harambot_banner.png)
# Harambot
_An interactive Yahoo Fantasy sports bot for Discord._

![Python](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10-blue) ![License](https://img.shields.io/badge/License-MIT-green) ![Build](https://img.shields.io/github/actions/workflow/status/DMcP89/harambot/pytest.yml?branch=main) ![Version](https://img.shields.io/badge/version-0.3.3--Beta-red)
![Python](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10-blue) ![License](https://img.shields.io/badge/License-MIT-green) ![Build](https://img.shields.io/github/actions/workflow/status/DMcP89/harambot/pytest.yml?branch=main) ![Version](https://img.shields.io/badge/version-0.4.0--Beta-red)


![harambot-logo](https://raw.githubusercontent.com/DMcP89/harambot/main/assests/harambot-1.jpg)



Expand All @@ -17,12 +18,13 @@ _An interactive Yahoo Fantasy sports bot for Discord._
/ping - Gives the latency of harambot
/RIP - Pay respects
/standings - Returns the current standings of the current league
/roster "Team name" - Returns the roster of the given team
/stats "Player Name" - Returns the details of the given player
/trade - Create poll for latest trade for league approval
/matchups - Returns the current weeks matchups
/waiver - Returns the waiver wire tranasactions from the previous 24 hours
/roster Team - Returns the roster of the given team
/stats Player - Returns the details of the given player
/trade - Create a poll for latest trade for league approval
/matchups week - Returns the matchups for the given week, defaults to the current week
/waiver days - Returns the waiver wire transactions from the previous number of days
/configure - Configure the bot for your guild
/reports - Set what channel transaction reports should be sent to.

You can find example output of these commands [here](https://github.com/DMcP89/harambot/wiki#command-examples)

Expand All @@ -39,13 +41,10 @@ In order to properly configure your bot you will need the following:

_Visit our [wiki](https://github.com/DMcP89/harambot/wiki) for a step by step guide on how to obtain these values._

### Run the bot in the cloud
### Run the bot on [Render](https://render.com/)

[![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/DMcP89/harambot)

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)


### Run the bot locally using pip package

1. Install the harambot package using pip
Expand All @@ -59,6 +58,7 @@ _Visit our [wiki](https://github.com/DMcP89/harambot/wiki) for a step by step gu
export YAHOO_KEY='[YOUR YAHOO API CLIENT ID]'
export YAHOO_SECRET='[YOUR YAHOO API CLIENT SECRET]'
export DATABASE_URL='[YOUR DATABASE URL]'
export HARAMBOT_KEY='[YOUR ENCRYPTION KEY]' # A URL-safe base64-encoded 32-byte key
```

3. Run the bot
Expand All @@ -78,6 +78,7 @@ _Visit our [wiki](https://github.com/DMcP89/harambot/wiki) for a step by step gu
export YAHOO_KEY='[YOUR YAHOO API CLIENT ID]'
export YAHOO_SECRET='[YOUR YAHOO API CLIENT SECRET]'
export DATABASE_URL='[YOUR DATABASE URL]'
export HARAMBOT_KEY='[YOUR ENCRYPTION KEY]' # A URL-safe base64-encoded 32-byte key
```

3. Run the bot
Expand All @@ -87,6 +88,7 @@ _Visit our [wiki](https://github.com/DMcP89/harambot/wiki) for a step by step gu
-e YAHOO_KEY=$YAHOO_KEY \
-e YAHOO_SECRET=$YAHOO_SECRET \
-e DATABASE_URL=$DATABASE_URL \
-e HARAMBOT_KEY=$HARAMBOT_KEY \
--rm dmcp89/harambot


Expand All @@ -102,21 +104,13 @@ _Visit our [wiki](https://github.com/DMcP89/harambot/wiki) for a step by step gu
* Read Message History
* Add Reactions
* Use Slash Commands
* Manage WebHooks

The permission value should be 277025507392
The permission value should be 277562378304

![discord-oauth](https://raw.githubusercontent.com/DMcP89/harambot/main/assests/discord-oauth-generator.png)

2. Set the gateway intents

In order for the bot to work properly it requires the following intents:

* Sever Members Intent
* Message Content Intent

![discord-intents](https://raw.githubusercontent.com/DMcP89/harambot/main/assests/discord-intents.png)

3. Navigate to the generated url in a web browser and authorize the bot for your guild
2. Navigate to the generated url in a web browser and authorize the bot for your guild

![discord-oauth-url-1](https://raw.githubusercontent.com/DMcP89/harambot/main/assests/discord-oauth-url-authorize-1.png)
![discord-oauth-url-2](https://raw.githubusercontent.com/DMcP89/harambot/main/assests/discord-oauth-url-authorize-2.png)
Expand Down
36 changes: 0 additions & 36 deletions app.json

This file was deleted.

Binary file added assests/harambot_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assests/harambot_config_dm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assests/harambot_webhook_permissions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assests/harambot_webhook_permissions_channel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assests/heroku-deployment.png
Binary file not shown.
Binary file removed assests/heroku-dyno.png
Binary file not shown.
Binary file added assests/reports.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assests/reports_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assests/waiver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion config/settings.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[default]
LOGLEVEL = "DEBUG"
VERSION = "0.3.1-Beta"
VERSION = "0.4.0-Beta"
RUN_MIGRATIONS = false
PORT = 10000
WEBHOOK_AVATAR_URL = "https://raw.githubusercontent.com/DMcP89/harambot/main/assests/harambot-1.jpg"
REPORT_EXECUTORS = 5
File renamed without changes.
File renamed without changes.
34 changes: 34 additions & 0 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM python:3.10.7-slim as python-base
ENV PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100
ENV PATH="/root/.local/bin:$PATH"

RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y gcc libc-dev make git libffi-dev python3-dev libxml2-dev libxslt-dev
RUN apt-get install -y default-libmysqlclient-dev pkg-config
RUN apt-get install -y libpq-dev

FROM python-base as poetry
RUN apt-get install --no-install-recommends -y \
# deps for installing poetry
curl \
# deps for building python deps
build-essential

# install poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
RUN poetry --version
RUN poetry config virtualenvs.create false


# cleanup
RUN rm -rf /var/lib/apt/lists/

COPY . ./
RUN poetry install

FROM poetry as runtime
WORKDIR /app
CMD ["harambot"]
File renamed without changes.
Loading

0 comments on commit f801f6f

Please sign in to comment.