diff --git a/README.md b/README.md index eea3036..167bdb1 100644 --- a/README.md +++ b/README.md @@ -61,3 +61,6 @@ If you are stuck in any way shape or form you can always contact anyone who work - http://chillout.ueuo.com - http://trello.com/b/x02goBbW/sebis-bot-tutorial-roadmap +## Deploy to heroku +For testing purposes you can click the link below to build your own copy of this repo you just pick an app name fill in the config variables then switch it on in resources tab. +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/Annihilator708/Sebi-Machine/tree/development) diff --git a/app.json b/app.json new file mode 100644 index 0000000..d5d8b35 --- /dev/null +++ b/app.json @@ -0,0 +1,15 @@ +{ + "name":"sebi-machine", + "stack":"container", + "env": { + + "ownerlist": { + "description": "comma seperated list of owner ids", + "required": true + }, + "botkey": { + "description": "bot token", + "required": true + } + } +} diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000..2d41892 --- /dev/null +++ b/heroku.yml @@ -0,0 +1,3 @@ +build: + docker: + worker: dockerfile diff --git a/src/__main__.py b/src/__main__.py index 8b4ecd8..e6b15ea 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -10,6 +10,7 @@ import json import logging import random import traceback +import os import discord from discord.ext import commands @@ -98,4 +99,7 @@ client = SebiMachine() # I am 99% certain this is valid! with open(in_here('config', 'PrivateConfig.json')) as fp: PrivateConfig = json.load(fp) +if PrivateConfig["bot-key"] == '': + PrivateConfig["bot-key"] = os.getenv('botkey') + client.run(PrivateConfig["bot-key"]) diff --git a/src/cogs/example.py b/src/cogs/example.py index de1c1da..4a73cbc 100644 --- a/src/cogs/example.py +++ b/src/cogs/example.py @@ -17,7 +17,7 @@ class CogName: now = ctx.message.created_at msg = await ctx.send('Pong') sub = msg.created_at - now - await msg.edit(content=f'Pong, {sub.total_seconds() * 1000}') + await msg.edit(content=f'🏓Pong, **{sub.total_seconds() * 1000}ms**') def setup(bot): diff --git a/src/cogs/git.py b/src/cogs/git.py index b1072a3..a49ec95 100644 --- a/src/cogs/git.py +++ b/src/cogs/git.py @@ -30,23 +30,26 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import discord from discord.ext import commands import logging -from ..shared_libs.utils import paginate, run_command +from ..shared_libs.utils import paginate, run_command, loggable import asyncio -git_log = logging.getLogger('git') - -class Git: +class Git(loggable.Loggable): def __init__(self, bot): self.bot = bot - @commands.group(case_insensitive=True) + @commands.group(case_insensitive=True, invoke_without_command=True) async def git(self, ctx): """Run help git for more info""" - pass + await ctx.send('https://github.com/Annihilator708/Sebi-Machine/') + + @commands.command(case_insensitive=True, brief='Gets the Trello link.') + async def trello(self, ctx): + await ctx.send('') @git.command() async def pull(self, ctx): + self.logger.warning('Invoking git-pull') await ctx.trigger_typing() if ctx.author.id not in self.bot.ownerlist: return await ctx.send('Only my contributors can use me like this :blush:', delete_after=10) @@ -55,6 +58,8 @@ class Git: color=self.bot.embed_color) em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}') + # Pretty sure you can just do await run_command() if that is async, + # or run in a TPE otherwise. result = await asyncio.wait_for(self.bot.loop.create_task( run_command('git fetch --all')), 120) + '\n' result += await asyncio.wait_for(self.bot.loop.create_task( diff --git a/src/config/config.py b/src/config/config.py index b6f5acf..4604a78 100644 --- a/src/config/config.py +++ b/src/config/config.py @@ -3,6 +3,7 @@ import json import discord +import os class LoadConfig: """ @@ -14,7 +15,10 @@ class LoadConfig: self.config = json.load(fp) # Initialize config + self.ownerlist = self.config["ownerlist"] + if self.ownerlist == []: + self.ownerlist = [int(i) for i in os.getenv('ownerlist').split(',')] self.defaultprefix = self.config["prefix"] self.version = self.config["version"] self.display_name = self.config["display_name"]