-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from DMcP89/dev
0.2.0 Beta Release
- Loading branch information
Showing
32 changed files
with
309 additions
and
257 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 |
---|---|---|
|
@@ -18,3 +18,5 @@ coverage.xml | |
.venv | ||
.vscode | ||
.gitignore | ||
secrets.json | ||
.secrets.toml |
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
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
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 |
---|---|---|
|
@@ -10,4 +10,6 @@ guilds.json | |
# Ignore dynaconf secret files | ||
.secrets.* | ||
answers.txt | ||
*.pem | ||
*.pem | ||
.python-version | ||
*.db |
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,15 +1,24 @@ | ||
FROM python:3.7.4-slim | ||
FROM python:3.10.7-slim | ||
|
||
WORKDIR /app/harambot | ||
|
||
ADD . /app/harambot | ||
ADD ./Makefile /app/harambot | ||
ADD ./requirements.txt /app/harambot/ | ||
ADD ./harambot /app/harambot/harambot | ||
ADD ./config /app/harambot/config | ||
|
||
RUN apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install -y gcc libc-dev make git libffi-dev python3-dev libxml2-dev libxslt-dev | ||
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 | ||
|
||
RUN apt-get install -y libpq-dev | ||
|
||
RUN pip install -U pip | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
CMD ["make", "run"] | ||
RUN ls -ltr /app/harambot | ||
|
||
CMD ["python", "./harambot/bot.py"] |
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
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 @@ | ||
worker: make run |
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,5 +1,8 @@ | ||
# Harambot | ||
[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-360/) | ||
![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/workflow/status/DMcP89/harambot/Pytest) | ||
|
||
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) | ||
|
||
|
||
A Yahoo Fantasy sports bot for Discord. | ||
|
||
|
@@ -8,7 +11,7 @@ A Yahoo Fantasy sports bot for Discord. | |
$RIP - Pay respects | ||
$standings - Returns the current standings of the current league | ||
$roster "Team name" - Returns the roster of the given team | ||
$player_details "Player Name" - Returns the details of the given player | ||
$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 | ||
|
||
|
@@ -17,7 +20,6 @@ A Yahoo Fantasy sports bot for Discord. | |
In order to properly configure your bot you will need the following: | ||
|
||
* Discord API Token | ||
* Discord Guild ID | ||
* Yahoo API Client Id & Secret | ||
* Yahoo League ID | ||
|
||
|
@@ -31,13 +33,6 @@ In order to properly configure your bot you will need the following: | |
4. Click the "Copy" button under token to copy your bots API token to your clipboard | ||
![discord-copy-token](/assests/discord-copy-token.png) | ||
|
||
### Discord Guild ID | ||
1. Open the discord web app - https://discord.com/app | ||
2. Navigate to your guild | ||
3. Copy the guild ID from the url | ||
``` | ||
https://discord.com/channels/[guild-id-is-here]/12345678910 | ||
``` | ||
|
||
### Yahoo API Client ID & Secret | ||
|
||
|
@@ -53,44 +48,65 @@ In order to properly configure your bot you will need the following: | |
You can find your league's ID under the settings page of your league | ||
![yahoo-league-id](/assests/yahoo-league-id.png) | ||
|
||
## Install | ||
## Deployment | ||
|
||
### Heroku | ||
|
||
Harambot now supports heroku deployments! | ||
|
||
Click the button at the top and fill out the form with your discord token and yahoo api client key and and secret. | ||
|
||
![heroku-deployment](/assests/heroku-deployment.png) | ||
|
||
### Local deployment | ||
1. Clone this repository | ||
|
||
git clone [email protected]:DMcP89/harambot.git | ||
cd harambot | ||
|
||
2. Configure the bot | ||
|
||
* Create a copy of example.secrets.toml named .secrets.toml | ||
``` | ||
cd config | ||
cp example.secrets.toml .secrets.toml | ||
``` | ||
* Update .secrets.toml with the values from the prerequisites section | ||
``` | ||
[default] | ||
DISCORD_TOKEN = 'Discord API Token' | ||
YAHOO_KEY = 'Yahoo Client ID' | ||
YAHOO_SECRET = 'Yahoo Client Secret' | ||
``` | ||
* Run make configure from the root directory | ||
``` | ||
cd .. | ||
make configure | ||
``` | ||
3. Run the bot. | ||
2. Run the bot. | ||
|
||
### On local machine | ||
make run | ||
### With Docker | ||
make build-docker | ||
make build-image | ||
make run-docker | ||
|
||
## Setup | ||
|
||
### Add the bot to your guild | ||
1. Generate a OAuth url from the discord developer portal using the bot scope and the following permissions: | ||
|
||
* Send Messages | ||
* Send Messages in Threads | ||
* Embed Links | ||
* Attach Files | ||
* Read Message History | ||
* Add Reactions | ||
* Use Slash Commands | ||
|
||
The permission value should be 277025507392 | ||
|
||
![discord-oauth](/assests/discord-oauth-generator.png) | ||
|
||
2. Navigate to the generated url in a web browser and authorize the bot for your guild | ||
|
||
![discord-oauth-url-1](/assests/discord-oauth-url-authorize-1.png) | ||
![discord-oauth-url-2](/assests/discord-oauth-url-authorize-2.png) | ||
|
||
### Configure your guild | ||
|
||
1. From your guild run the configure slash command | ||
|
||
![discord-config-command](/assests/discord-config-command.png) | ||
|
||
2. The bot will DM you to complete the guild setup | ||
|
||
![discord-config-dm](/assests/discord-config-dm.png) | ||
|
||
## Command Examples | ||
|
||
### $player_details Rashaad Penny | ||
### $stats Rashaad Penny | ||
|
||
![player-details](/assests/player_details.PNG) | ||
|
||
|
@@ -117,7 +133,4 @@ You can find your league's ID under the settings page of your league | |
|
||
### $RIP "My Season" | ||
|
||
![rip](/assests/rip.PNG) | ||
## Support Harambot! | ||
<a href="https://www.buymeacoffee.com/wochstudios" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a> | ||
![rip](/assests/rip.PNG) |
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,36 @@ | ||
{ | ||
"name": "Harambot", | ||
"description": "A Yahoo Fantasy sports bot for Discord.", | ||
"keywords": [ | ||
"fantasy football", | ||
"discord", | ||
"yahoo", | ||
"chat bot", | ||
"ff", | ||
"harambe" | ||
], | ||
"website" : "https://github.com/DMcP89/harambot", | ||
"repository": "https://github.com/DMcP89/harambot", | ||
"env": { | ||
"YAHOO_KEY" : { | ||
"description": "Yahoo Consumer Key", | ||
"value": "", | ||
"required": "true" | ||
}, | ||
"YAHOO_SECRET" : { | ||
"description": "Yahoo Consumer Secret", | ||
"value": "", | ||
"required": "true" | ||
}, | ||
"DISCORD_TOKEN" : { | ||
"description": "Discord bot token", | ||
"value": "", | ||
"required": "true" | ||
} | ||
}, | ||
"addons": [ | ||
"heroku-postgresql" | ||
] | ||
|
||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,4 +1,10 @@ | ||
[default] | ||
DISCORD_TOKEN = 'Discord API Token' | ||
YAHOO_KEY = 'Yahoo Client ID' | ||
YAHOO_SECRET = 'Yahoo Client Secret' | ||
YAHOO_SECRET = 'Yahoo Client Secret' | ||
GUILD_DB = 'harambot' | ||
GUILD_DB_USER = 'harambot' | ||
GUILD_DB_PASS = 'harambe' | ||
GUILD_DB_HOST = 'localhost' | ||
GUILD_DB_PORT = 3308 | ||
DATABASE_URL = 'sqlite:///harambot.db' |
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,3 +1,6 @@ | ||
[default] | ||
LOGLEVEL = "DEBUG" | ||
GUILDS_DATASTORE_LOC = "config/guilds.json" | ||
# Supported databases are sqlite, mysql, and postgres | ||
GUILDS_DATASTORE_TYPE = "sqlite" | ||
# if using a sqlite database specify the path to the db file | ||
GUILDS_DATASTORE_LOC = "harambot.db" |
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,53 @@ | ||
import os | ||
|
||
import logging | ||
import discord | ||
import requests | ||
import base64 | ||
import time | ||
from yahoo_fantasy_api import game | ||
from yahoo_oauth import OAuth2 | ||
|
||
|
||
from discord.ext import commands | ||
from cogs.meta import Meta | ||
from cogs.misc import Misc | ||
from cogs.yahoo import Yahoo | ||
from config import settings | ||
from database.models import Guild | ||
from utils import configure_guild | ||
|
||
#logging.basicConfig(level=logging.INFO) | ||
logger = logging.getLogger('harambot.py') | ||
logger.setLevel(settings.loglevel) | ||
|
||
intents = discord.Intents.default() | ||
intents.members = True | ||
intents.messages = True | ||
intents.message_content = True | ||
|
||
bot = commands.Bot(command_prefix="$", description="", intents=intents) | ||
bot.remove_command('help') | ||
|
||
|
||
|
||
@bot.event | ||
async def on_ready(): | ||
await bot.add_cog(Meta(bot)) | ||
await bot.add_cog(Yahoo(bot, settings.yahoo_key, settings.yahoo_secret)) | ||
await bot.add_cog(Misc(bot)) | ||
if not Guild.table_exists(): | ||
Guild.create_table() | ||
for guild in bot.guilds: | ||
bot.tree.copy_global_to(guild=guild) | ||
await bot.tree.sync(guild=guild) | ||
logger.info("Everything's all ready to go~") | ||
|
||
@bot.event | ||
async def on_guild_join(guild): | ||
logger.info("Joined {}".format(guild.name)) | ||
if not Guild.select().where(Guild.guild_id == str(guild.id)).exists(): | ||
await configure_guild(bot,guild.owner, guild.id) | ||
logger.info("Guild not configured!") | ||
|
||
bot.run(settings.discord_token, reconnect=True) # Where 'TOKEN' is your bot token |
Oops, something went wrong.