From 6bcae420806542d659155599d5038cdfaff8540c Mon Sep 17 00:00:00 2001 From: Raatty <39517058+Raatty@users.noreply.github.com> Date: Wed, 23 May 2018 12:04:31 +1200 Subject: [PATCH 01/11] Styling ping command --- src/cogs/example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cogs/example.py b/src/cogs/example.py index de1c1da..4c62f25 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}**') def setup(bot): From 523485461f32a150cca828988be1350ada781c53 Mon Sep 17 00:00:00 2001 From: Raatty <39517058+Raatty@users.noreply.github.com> Date: Wed, 23 May 2018 12:07:57 +1200 Subject: [PATCH 02/11] Units added to ping --- src/cogs/example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cogs/example.py b/src/cogs/example.py index 4c62f25..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): From 88f2c4d0872f9c1a4cc86e61f921bd327105aa8b Mon Sep 17 00:00:00 2001 From: Raatty <39517058+Raatty@users.noreply.github.com> Date: Wed, 23 May 2018 20:32:20 +1200 Subject: [PATCH 03/11] Development (#16) * heroku yml * owner list from env * bot key from enviroment var * app json * heroku button * again * Update README.md * fixing syntax hopefully * error fixing * enviroments added * opsy forgot a } * trying again * Update app.json * Update app.json * Update app.json * Update app.json * Update app.json * Update __main__.py * Update app.json * Update __main__.py * removed prints --- README.md | 2 +- app.json | 15 +++++++++++++++ heroku.yml | 3 +++ src/__main__.py | 4 ++++ src/config/config.py | 6 +++++- 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 app.json create mode 100644 heroku.yml diff --git a/README.md b/README.md index eea3036..0e1e939 100644 --- a/README.md +++ b/README.md @@ -60,4 +60,4 @@ If you are stuck in any way shape or form you can always contact anyone who work - http://discord.gg/GWdhBSp - http://chillout.ueuo.com - http://trello.com/b/x02goBbW/sebis-bot-tutorial-roadmap - +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/Raatty/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/config/config.py b/src/config/config.py index b6f5acf..fe00265 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.config["ownerlist"] != []: + self.ownerlist = self.config["ownerlist"] + else: + 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"] From bc8e8d62de4582f31c834773f432fe3c454df780 Mon Sep 17 00:00:00 2001 From: Raatty <39517058+Raatty@users.noreply.github.com> Date: Wed, 23 May 2018 20:33:11 +1200 Subject: [PATCH 04/11] updated link to point to this repo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e1e939..b07651e 100644 --- a/README.md +++ b/README.md @@ -60,4 +60,4 @@ If you are stuck in any way shape or form you can always contact anyone who work - http://discord.gg/GWdhBSp - http://chillout.ueuo.com - http://trello.com/b/x02goBbW/sebis-bot-tutorial-roadmap -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/Raatty/Sebi-Machine/tree/development) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/Annihilator708/Sebi-Machine/tree/development) From 437da83d86fab917c0791689c03441469a3568c5 Mon Sep 17 00:00:00 2001 From: Raatty <39517058+Raatty@users.noreply.github.com> Date: Wed, 23 May 2018 20:37:56 +1200 Subject: [PATCH 05/11] added docs for the heroku button --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b07651e..167bdb1 100644 --- a/README.md +++ b/README.md @@ -60,4 +60,7 @@ If you are stuck in any way shape or form you can always contact anyone who work - http://discord.gg/GWdhBSp - 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) From f40c5eae0e70ec453f1a5266d34d4d9fee91e752 Mon Sep 17 00:00:00 2001 From: Raatty <39517058+Raatty@users.noreply.github.com> Date: Wed, 23 May 2018 22:41:34 +1200 Subject: [PATCH 06/11] displays git url when you do git command with no arguments --- src/cogs/git.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cogs/git.py b/src/cogs/git.py index b1072a3..2354a42 100644 --- a/src/cogs/git.py +++ b/src/cogs/git.py @@ -43,7 +43,8 @@ class Git: @commands.group(case_insensitive=True) async def git(self, ctx): """Run help git for more info""" - pass + if ctx.invoked_subcommand is None: + ctx.send('https://github.com/Annihilator708/Sebi-Machine/') @git.command() async def pull(self, ctx): From 8aee156b45961adeefb9e28ebb774df98fa81a5f Mon Sep 17 00:00:00 2001 From: Raatty <39517058+Raatty@users.noreply.github.com> Date: Wed, 23 May 2018 22:47:51 +1200 Subject: [PATCH 07/11] Update git.py --- src/cogs/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cogs/git.py b/src/cogs/git.py index 2354a42..9f42323 100644 --- a/src/cogs/git.py +++ b/src/cogs/git.py @@ -40,7 +40,7 @@ class Git: def __init__(self, bot): self.bot = bot - @commands.group(case_insensitive=True) + @commands.group(case_insensitive=True, invoke_without_subcommand=True) async def git(self, ctx): """Run help git for more info""" if ctx.invoked_subcommand is None: From deb9a53e6ee69b7599ab934a94e22547558251b0 Mon Sep 17 00:00:00 2001 From: Raatty <39517058+Raatty@users.noreply.github.com> Date: Wed, 23 May 2018 22:51:50 +1200 Subject: [PATCH 08/11] Update git.py --- src/cogs/git.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cogs/git.py b/src/cogs/git.py index 9f42323..22d3814 100644 --- a/src/cogs/git.py +++ b/src/cogs/git.py @@ -40,11 +40,10 @@ class Git: def __init__(self, bot): self.bot = bot - @commands.group(case_insensitive=True, invoke_without_subcommand=True) + @commands.group(case_insensitive=True, invoke_without_command=True) async def git(self, ctx): """Run help git for more info""" - if ctx.invoked_subcommand is None: - ctx.send('https://github.com/Annihilator708/Sebi-Machine/') + ctx.send('https://github.com/Annihilator708/Sebi-Machine/') @git.command() async def pull(self, ctx): From 8e05970ac64aac4acadad9d3b786aad8a2310217 Mon Sep 17 00:00:00 2001 From: Raatty <39517058+Raatty@users.noreply.github.com> Date: Wed, 23 May 2018 22:57:42 +1200 Subject: [PATCH 09/11] await lolz --- src/cogs/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cogs/git.py b/src/cogs/git.py index 22d3814..3112b9b 100644 --- a/src/cogs/git.py +++ b/src/cogs/git.py @@ -43,7 +43,7 @@ class Git: @commands.group(case_insensitive=True, invoke_without_command=True) async def git(self, ctx): """Run help git for more info""" - ctx.send('https://github.com/Annihilator708/Sebi-Machine/') + await ctx.send('https://github.com/Annihilator708/Sebi-Machine/') @git.command() async def pull(self, ctx): From 124df7eab12fb6a96bf5b2012089f0e1ef6c2369 Mon Sep 17 00:00:00 2001 From: Espy | Neko | 404 <34942042+neko404notfound@users.noreply.github.com> Date: Wed, 23 May 2018 12:05:03 +0100 Subject: [PATCH 10/11] Update git.py (#18) --- src/cogs/git.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cogs/git.py b/src/cogs/git.py index 3112b9b..a49ec95 100644 --- a/src/cogs/git.py +++ b/src/cogs/git.py @@ -30,13 +30,11 @@ 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 @@ -44,9 +42,14 @@ class Git: async def git(self, ctx): """Run help git for more info""" 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( From dc3a34651f9ef8f12982ba1d26747e05dbc58678 Mon Sep 17 00:00:00 2001 From: Raatty <39517058+Raatty@users.noreply.github.com> Date: Thu, 24 May 2018 00:23:36 +1200 Subject: [PATCH 11/11] Ajusted the ownerlist from env varable if bank to be less destructive --- src/config/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/config/config.py b/src/config/config.py index fe00265..4604a78 100644 --- a/src/config/config.py +++ b/src/config/config.py @@ -15,9 +15,9 @@ class LoadConfig: self.config = json.load(fp) # Initialize config - if self.config["ownerlist"] != []: - self.ownerlist = self.config["ownerlist"] - else: + + 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"]