Skip to content

Commit

Permalink
Merge pull request #101 from DMcP89/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DMcP89 authored Jun 18, 2023
2 parents d4f2763 + cb4344e commit 98cd2da
Show file tree
Hide file tree
Showing 9 changed files with 641 additions and 569 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ RUN pip install -U pip

RUN pip install harambot

EXPOSE 10000

CMD ["harambot"]
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Harambot
![harambot-logo](./assests/harambot-1.jpg)

![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)
![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.1--Beta-red)

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
[![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)

An interactive Yahoo Fantasy sports bot for Discord.

Expand Down
3 changes: 2 additions & 1 deletion config/settings.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[default]
LOGLEVEL = "DEBUG"
VERSION = "0.0.3-Beta"
VERSION = "0.3.1-Beta"
RUN_MIGRATIONS = false
PORT = 10000
6 changes: 6 additions & 0 deletions harambot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from harambot.cogs.meta import Meta
from harambot.cogs.misc import Misc
from harambot.cogs.yahoo import YahooCog

from harambot.cogs.webserver import WebServer
from harambot.config import settings
from harambot.database.models import Guild
from harambot.database.migrations import migrations
Expand All @@ -31,6 +33,10 @@ async def on_ready():
await bot.add_cog(Meta(bot))
await bot.add_cog(YahooCog(bot, settings.yahoo_key, settings.yahoo_secret))
await bot.add_cog(Misc(bot))
server = WebServer(bot)
await bot.add_cog(server)
bot.loop.create_task(server.webserver())

if not Guild.table_exists():
Guild.create_table()
if "RUN_MIGRATIONS" in settings and settings.run_migrations:
Expand Down
33 changes: 33 additions & 0 deletions harambot/cogs/webserver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from aiohttp import web
from discord.ext import commands
from harambot.config import settings

import logging

logger = logging.getLogger(__file__)
logger.setLevel(logging.INFO)


class WebServer(commands.Cog):
def __init__(self, bot):
self.bot = bot

async def webserver(self):
async def handler(request):
status = f"""
Harambot
Harambot v{settings.version} is running!
Bot status: {request.config_dict["bot"].status}
Latency: {round(request.config_dict["bot"].latency * 1000)}ms
"""
return web.Response(text=status)

app = web.Application()
app.router.add_get("/", handler)
app["bot"] = self.bot
runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(runner, "0.0.0.0", settings.port)
await self.bot.wait_until_ready()
await site.start()
logger.info("Webserver started on port {}".format(settings.port))
1,022 changes: 514 additions & 508 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "harambot"
version = "0.3.0"
version = "0.3.1"
description = "A Yahoo Fantasy Sports bot for Discord"
authors = ["DMcP89 <[email protected]>"]
license = "MIT"
Expand Down Expand Up @@ -29,7 +29,7 @@ packages = [

[tool.poetry.dependencies]
python = "^3.8"
discord = "^2.1.0"
"discord.py" = "^2.1.0"
dynaconf = "^3.1.11"
peewee = "^3.15.4"
cachetools = "^5.2.0"
Expand Down
24 changes: 24 additions & 0 deletions render.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
services:
- type: web
name: harambot-servicet
runtime: image
image:
url: docker.io/dmcp89/harambot:latest
plan: free
envVars:
- key: DISCORD_TOKEN
sync: false
- key: YAHOO_KEY
sync: false
- key: YAHOO_SECRET
sync: false
- key: DATABASE_URL
fromDatabase:
name: harambot-database
property: connectionString

databases:
- name: harambot-database
databaseName: harambot
user: harambot
plan: free
111 changes: 55 additions & 56 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,56 +1,55 @@
aiohttp==3.8.3 ; python_version >= "3.8" and python_version < "4.0"
aiosignal==1.3.1 ; python_version >= "3.8" and python_version < "4.0"
async-timeout==4.0.2 ; python_version >= "3.8" and python_version < "4.0"
attrs==22.1.0 ; python_version >= "3.8" and python_version < "4.0"
black==22.10.0 ; python_version >= "3.8" and python_version < "4.0"
cachetools==5.2.0 ; python_version >= "3.8" and python_version < "4.0"
certifi==2022.12.7 ; python_version >= "3.8" and python_version < "4"
cfgv==3.3.1 ; python_version >= "3.8" and python_version < "4.0"
charset-normalizer==2.1.1 ; python_version >= "3.8" and python_version < "4.0"
click==8.1.3 ; python_version >= "3.8" and python_version < "4.0"
colorama==0.4.6 ; python_version >= "3.8" and python_version < "4.0" and sys_platform == "win32" or python_version >= "3.8" and python_version < "4.0" and platform_system == "Windows"
coverage[toml]==6.5.0 ; python_version >= "3.8" and python_version < "4.0"
discord-py==2.1.0 ; python_version >= "3.8" and python_version < "4.0"
discord==2.1.0 ; python_version >= "3.8" and python_version < "4.0"
distlib==0.3.6 ; python_version >= "3.8" and python_version < "4.0"
docopt==0.6.2 ; python_version >= "3.8" and python_version < "4.0"
dynaconf==3.1.11 ; python_version >= "3.8" and python_version < "4.0"
exceptiongroup==1.0.4 ; python_version >= "3.8" and python_version < "3.11"
filelock==3.8.0 ; python_version >= "3.8" and python_version < "4.0"
flake8==5.0.4 ; python_version >= "3.8" and python_version < "4.0"
frozenlist==1.3.3 ; python_version >= "3.8" and python_version < "4.0"
identify==2.5.8 ; python_version >= "3.8" and python_version < "4.0"
idna==3.4 ; python_version >= "3.8" and python_version < "4.0"
iniconfig==1.1.1 ; python_version >= "3.8" and python_version < "4.0"
mccabe==0.7.0 ; python_version >= "3.8" and python_version < "4.0"
multidict==6.0.2 ; python_version >= "3.8" and python_version < "4.0"
mypy-extensions==0.4.3 ; python_version >= "3.8" and python_version < "4.0"
mysqlclient==2.1.1 ; python_version >= "3.8" and python_version < "4.0"
nodeenv==1.7.0 ; python_version >= "3.8" and python_version < "4.0"
objectpath==0.6.1 ; python_version >= "3.8" and python_version < "4.0"
packaging==21.3 ; python_version >= "3.8" and python_version < "4.0"
pathspec==0.10.2 ; python_version >= "3.8" and python_version < "4.0"
peewee==3.15.4 ; python_version >= "3.8" and python_version < "4.0"
platformdirs==2.5.4 ; python_version >= "3.8" and python_version < "4.0"
pluggy==1.0.0 ; python_version >= "3.8" and python_version < "4.0"
pre-commit==2.20.0 ; python_version >= "3.8" and python_version < "4.0"
psycopg2==2.9.5 ; python_version >= "3.8" and python_version < "4.0"
pyaml==21.10.1 ; python_version >= "3.8" and python_version < "4.0"
pycodestyle==2.9.1 ; python_version >= "3.8" and python_version < "4.0"
pyflakes==2.5.0 ; python_version >= "3.8" and python_version < "4.0"
pyparsing==3.0.9 ; python_version >= "3.8" and python_version < "4.0"
pytest-cov==4.0.0 ; python_version >= "3.8" and python_version < "4.0"
pytest==7.2.0 ; python_version >= "3.8" and python_version < "4.0"
pytz==2023.2 ; python_version >= "3.8" and python_version < "4.0"
pyyaml==6.0 ; python_version >= "3.8" and python_version < "4.0"
rauth==0.7.3 ; python_version >= "3.8" and python_version < "4.0"
requests==2.28.2 ; python_version >= "3.8" and python_version < "4"
setuptools==65.5.1 ; python_version >= "3.8" and python_version < "4.0"
toml==0.10.2 ; python_version >= "3.8" and python_version < "4.0"
tomli==2.0.1 ; python_version >= "3.8" and python_full_version < "3.11.0a7"
typing-extensions==4.4.0 ; python_version >= "3.8" and python_version < "3.10"
urllib3==1.26.15 ; python_version >= "3.8" and python_version < "4"
virtualenv==20.16.7 ; python_version >= "3.8" and python_version < "4.0"
yahoo-fantasy-api==2.7.0 ; python_version >= "3.8" and python_version < "4.0"
yahoo-oauth==2.0 ; python_version >= "3.8" and python_version < "4.0"
yarl==1.8.1 ; python_version >= "3.8" and python_version < "4.0"
aiohttp==3.8.3
aiosignal==1.3.1
async-timeout==4.0.2
attrs==22.1.0
black==22.10.0
cachetools==5.2.0
certifi==2022.12.7
cfgv==3.3.1
charset-normalizer==2.1.1
click==8.1.3
colorama==0.4.6
coverage[toml]==6.5.0
discord.py==2.1.0
distlib==0.3.6
docopt==0.6.2
dynaconf==3.1.11
exceptiongroup==1.0.4
filelock==3.8.0
flake8==5.0.4
frozenlist==1.3.3
identify==2.5.8
idna==3.4
iniconfig==1.1.1
mccabe==0.7.0
multidict==6.0.2
mypy-extensions==0.4.3
mysqlclient==2.1.1
nodeenv==1.7.0
objectpath==0.6.1
packaging==21.3
pathspec==0.10.2
peewee==3.15.4
platformdirs==2.5.4
pluggy==1.0.0
pre-commit==2.20.0
psycopg2==2.9.5
pyaml==21.10.1
pycodestyle==2.9.1
pyflakes==2.5.0
pyparsing==3.0.9
pytest-cov==4.0.0
pytest==7.2.0
pytz==2023.2
pyyaml==6.0
rauth==0.7.3
requests==2.28.2
setuptools==65.5.1
toml==0.10.2
tomli==2.0.1
typing-extensions==4.4.0
urllib3==1.26.15
virtualenv==20.16.7
yahoo-fantasy-api==2.7.0
yahoo-oauth==2.0
yarl==1.8.1

0 comments on commit 98cd2da

Please sign in to comment.