Merge branch 'development' of https://github.com/Annihilator708/Sebi-Machine into development

This commit is contained in:
annihilator708
2018-05-23 18:42:35 +02:00
7 changed files with 41 additions and 7 deletions
+3
View File
@@ -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://chillout.ueuo.com
- http://trello.com/b/x02goBbW/sebis-bot-tutorial-roadmap - 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)
+15
View File
@@ -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
}
}
}
+3
View File
@@ -0,0 +1,3 @@
build:
docker:
worker: dockerfile
+4
View File
@@ -10,6 +10,7 @@ import json
import logging import logging
import random import random
import traceback import traceback
import os
import discord import discord
from discord.ext import commands from discord.ext import commands
@@ -98,4 +99,7 @@ client = SebiMachine()
# I am 99% certain this is valid! # I am 99% certain this is valid!
with open(in_here('config', 'PrivateConfig.json')) as fp: with open(in_here('config', 'PrivateConfig.json')) as fp:
PrivateConfig = json.load(fp) PrivateConfig = json.load(fp)
if PrivateConfig["bot-key"] == '':
PrivateConfig["bot-key"] = os.getenv('botkey')
client.run(PrivateConfig["bot-key"]) client.run(PrivateConfig["bot-key"])
+1 -1
View File
@@ -17,7 +17,7 @@ class CogName:
now = ctx.message.created_at now = ctx.message.created_at
msg = await ctx.send('Pong') msg = await ctx.send('Pong')
sub = msg.created_at - now 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): def setup(bot):
+11 -6
View File
@@ -30,23 +30,26 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import discord import discord
from discord.ext import commands from discord.ext import commands
import logging import logging
from ..shared_libs.utils import paginate, run_command from ..shared_libs.utils import paginate, run_command, loggable
import asyncio import asyncio
git_log = logging.getLogger('git')
class Git(loggable.Loggable):
class Git:
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
@commands.group(case_insensitive=True) @commands.group(case_insensitive=True, invoke_without_command=True)
async def git(self, ctx): async def git(self, ctx):
"""Run help git for more info""" """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('<https://trello.com/b/x02goBbW/sebis-bot-tutorial-roadmap>')
@git.command() @git.command()
async def pull(self, ctx): async def pull(self, ctx):
self.logger.warning('Invoking git-pull')
await ctx.trigger_typing() await ctx.trigger_typing()
if ctx.author.id not in self.bot.ownerlist: 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) 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) color=self.bot.embed_color)
em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}') 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( result = await asyncio.wait_for(self.bot.loop.create_task(
run_command('git fetch --all')), 120) + '\n' run_command('git fetch --all')), 120) + '\n'
result += await asyncio.wait_for(self.bot.loop.create_task( result += await asyncio.wait_for(self.bot.loop.create_task(
+4
View File
@@ -3,6 +3,7 @@
import json import json
import discord import discord
import os
class LoadConfig: class LoadConfig:
""" """
@@ -14,7 +15,10 @@ class LoadConfig:
self.config = json.load(fp) self.config = json.load(fp)
# Initialize config # Initialize config
self.ownerlist = self.config["ownerlist"] 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.defaultprefix = self.config["prefix"]
self.version = self.config["version"] self.version = self.config["version"]
self.display_name = self.config["display_name"] self.display_name = self.config["display_name"]