-
-
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 #93 from DMcP89/dev
Merging changes for 0.3.0-Beta Release
- Loading branch information
Showing
41 changed files
with
5,212 additions
and
437 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 |
---|---|---|
|
@@ -19,4 +19,4 @@ coverage.xml | |
.vscode | ||
.gitignore | ||
secrets.json | ||
.secrets.toml | ||
.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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,3 @@ labels: '' | |
assignees: '' | ||
|
||
--- | ||
|
||
|
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,27 @@ | ||
## Description | ||
|
||
<!--- Describe your changes in detail here. --> | ||
|
||
## Types of Changes | ||
|
||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> | ||
- [ ] Core | ||
- [ ] Bugfix | ||
- [ ] New feature | ||
- [ ] Enhancement/optimization | ||
|
||
## Issues Fixed or Closed by This PR | ||
|
||
* | ||
|
||
## Checklist | ||
|
||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. --> | ||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> | ||
- [ ] My code follows the code style of this project: [**Python**]() | ||
- [ ] I have read the [**PR Checklist** document]() and have made the appropriate changes. | ||
- [ ] My change requires a change to the documentation. | ||
- [ ] I have updated the documentation accordingly. | ||
- [ ] I have read the [**CONTRIBUTING** document](). | ||
- [ ] I have added tests to cover my changes. | ||
- [ ] I have tested the changes and verified that they work and don't break anything (as well as I can manage). |
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 |
---|---|---|
|
@@ -12,4 +12,9 @@ guilds.json | |
answers.txt | ||
*.pem | ||
.python-version | ||
*.db | ||
*.db | ||
|
||
# Pytest | ||
.coverage | ||
|
||
dist/ |
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,20 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
|
||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.8.3 | ||
hooks: | ||
- id: flake8 | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 22.10.0 | ||
hooks: | ||
- id: black |
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 |
---|---|---|
@@ -1,19 +1,21 @@ | ||
# Harambot | ||
![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) ![Version](https://img.shields.io/badge/version-0.2.1--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.3.0--Beta-red) | ||
|
||
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) | ||
|
||
|
||
A Yahoo Fantasy sports bot for Discord. | ||
|
||
## Commands | ||
$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 | ||
/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 | ||
/configure - Configure the bot for your guild | ||
|
||
## Prerequisites | ||
|
||
|
@@ -41,7 +43,7 @@ In order to properly configure your bot you will need the following: | |
2. Fill out the form as shown below, you can provide your own values for Application Name, Description, and Homepage URL. Once complete click the "Create App" button | ||
![yahoo-app-details](/assests/yahoo-app-details.png) | ||
3. Copy the Client ID and Client Secret values | ||
![yahoo-app-secrets](/assests/yahoo-app-secrets.png) | ||
![yahoo-app-secrets](/assests/yahoo-app-secrets.png) | ||
|
||
### Yahoo League ID | ||
|
||
|
@@ -54,21 +56,49 @@ You can find your league's ID under the settings page of your league | |
|
||
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. | ||
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) | ||
|
||
Once the deployment is complete enable the dyno | ||
|
||
![heroku-dyno](/assests/heroku-dyno.png) | ||
|
||
### Local deployment | ||
1. Clone this repository | ||
### Install package from PIP | ||
|
||
1. Install the harambot package using pip | ||
|
||
pip install harambot | ||
|
||
2. Export the following environment variables | ||
|
||
``` | ||
export DISCORD_TOKEN='[YOUR DISCORD TOKEN]' | ||
export YAHOO_KEY='[YOUR YAHOO API CLIENT ID]' | ||
export YAHOO_SECRET='[YOUR YAHOO API CLIENT SECRET]' | ||
export DATABASE_URL='[YOUR DATABASE URL]' | ||
``` | ||
|
||
3. Run the bot | ||
|
||
harambot | ||
|
||
### Run from source | ||
1. Clone this repository | ||
|
||
git clone [email protected]:DMcP89/harambot.git | ||
cd harambot | ||
|
||
2. Run the bot. | ||
2. Export the following environment variables | ||
|
||
``` | ||
export DISCORD_TOKEN='[YOUR DISCORD TOKEN]' | ||
export YAHOO_KEY='[YOUR YAHOO API CLIENT ID]' | ||
export YAHOO_SECRET='[YOUR YAHOO API CLIENT SECRET]' | ||
export DATABASE_URL='[YOUR DATABASE URL]' | ||
``` | ||
|
||
3. Run the bot. | ||
|
||
### On local machine | ||
make run | ||
|
@@ -109,13 +139,27 @@ In order for the bot to work properly it requires the following intents: | |
|
||
### Configure your guild | ||
|
||
* When the bot joins your guild for the first time it will DM you to complete the guild setup | ||
* Once your bot is added to your guild you can configure it by sending a direct message to the bot with the following command: | ||
|
||
|
||
![discord-config-commnd](/assests/harambot_configure_1.png) | ||
|
||
* Use the Login with Yahoo button to authenticate with Yahoo and get your Yahoo token | ||
|
||
|
||
![discord-config-yahoo](/assests/harambot_configure_4.png) | ||
|
||
* Use the Configure Guild button to configure your guild for the bot | ||
|
||
|
||
![discord-config-guild](/assests/harambot_configure_2.png) | ||
|
||
|
||
* You can reconfigure your guild by running the configure command and clicking the Configure Guild button. | ||
|
||
![discord-config-dm](/assests/discord-config-dm.png) | ||
|
||
* You can reconfigure your guild by running the configure slash command from your guild | ||
![discord-config-guild](/assests/harambot_configure_3.png) | ||
|
||
![discord-config-command](/assests/discord-config-command.png) | ||
|
||
## Command Examples | ||
|
||
|
@@ -146,4 +190,4 @@ In order for the bot to work properly it requires the following intents: | |
|
||
### $RIP "My Season" | ||
|
||
![rip](/assests/rip.PNG) | ||
![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
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
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,6 +1,4 @@ | ||
[default] | ||
LOGLEVEL = "DEBUG" | ||
# 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" | ||
VERSION = "0.0.3-Beta" | ||
RUN_MIGRATIONS = false |
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,50 +1,59 @@ | ||
import os | ||
|
||
import logging | ||
import discord | ||
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) | ||
from harambot.cogs.meta import Meta | ||
from harambot.cogs.misc import Misc | ||
from harambot.cogs.yahoo import YahooCog | ||
from harambot.config import settings | ||
from harambot.database.models import Guild | ||
from harambot.database.migrations import migrations | ||
|
||
# logging.basicConfig(level=logging.INFO) | ||
logger = logging.getLogger("harambot.py") | ||
if "LOGLEVEL" in settings: | ||
logger.setLevel(settings.loglevel) | ||
else: | ||
logger.setLevel("INFO") | ||
|
||
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.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(YahooCog(bot, settings.yahoo_key, settings.yahoo_secret)) | ||
await bot.add_cog(Misc(bot)) | ||
if not Guild.table_exists(): | ||
Guild.create_table() | ||
if "RUN_MIGRATIONS" in settings and settings.run_migrations: | ||
migrations[settings.version]() | ||
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 | ||
await guild.owner.send( | ||
"""Thank you for adding Harambot to your server! | ||
Please complete your setup by running the /configure command!""" | ||
) | ||
|
||
|
||
def run(): | ||
bot.run(settings.discord_token, reconnect=True) | ||
|
||
|
||
run() |
Oops, something went wrong.