Merge branch 'development' of https://github.com/dustinpianalto/Geeksbot into development

release-1.0.0
DustyP 8 years ago
commit 9f849bdf29

@ -28,7 +28,9 @@ class Git:
em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}') em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}')
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(run_command('git fetch --all')), 120) + '\n'
result += await asyncio.wait_for(self.bot.loop.create_task(run_command('git reset --hard ' result += await asyncio.wait_for(self.bot.loop.create_task(run_command('git reset --hard '
'origin/master')), 120) + '\n\n' 'origin/$(git '
'rev-parse --symbolic-full-name'
'--abbrev-ref HEAD)')), 120) + '\n\n'
result += await asyncio.wait_for(self.bot.loop.create_task(run_command('git show --stat | ' result += await asyncio.wait_for(self.bot.loop.create_task(run_command('git show --stat | '
'sed "s/.*@.*[.].*/ /g"')), 10) 'sed "s/.*@.*[.].*/ /g"')), 10)
results = paginate(result, maxlen=1014) results = paginate(result, maxlen=1014)

@ -91,3 +91,5 @@ async def run_command(args):
stdout, stderr = await process.communicate() stdout, stderr = await process.communicate()
# Return stdout # Return stdout
return stdout.decode().strip() return stdout.decode().strip()
# TODO Add Paginator

@ -159,7 +159,7 @@ class Repl:
if ctx.author.id != ownerid: if ctx.author.id != ownerid:
return return
try: try:
body = self.cleanup_code(body).split(' ') body = self.cleanup_code(body)
result = await asyncio.wait_for(self.bot.loop.create_task(run_command(body)), 10) result = await asyncio.wait_for(self.bot.loop.create_task(run_command(body)), 10)
value = result value = result
for page in paginate(value): for page in paginate(value):

@ -499,6 +499,7 @@ class Utils:
em.title = f'Google Search' em.title = f'Google Search'
em.description = f'Top 4 results for "{search}"' em.description = f'Top 4 results for "{search}"'
em.colour = embed_color em.colour = embed_color
# TODO Fix layout of Results
for result in results: for result in results:
em.add_field(name=f'{result["title"]}', value=f'{result["snippet"]}\n{result["link"]}') em.add_field(name=f'{result["title"]}', value=f'{result["snippet"]}\n{result["link"]}')
await ctx.send(embed=em) await ctx.send(embed=em)
@ -528,6 +529,8 @@ class Utils:
value=f'Steam ID: {steam[i]}\nPatreon Level: {tier[i]}\nPatron of: {patron[i]}') value=f'Steam ID: {steam[i]}\nPatreon Level: {tier[i]}\nPatron of: {patron[i]}')
await ctx.send(embed=em) await ctx.send(embed=em)
# TODO Create Help command
def setup(bot): def setup(bot):
bot.add_cog(Utils(bot)) bot.add_cog(Utils(bot))

@ -8,6 +8,8 @@ import aiohttp
from postgres import Postgres from postgres import Postgres
from collections import deque from collections import deque
from googleapiclient.discovery import build from googleapiclient.discovery import build
import asyncpg
log_format = '{asctime}.{msecs:03.0f}|{levelname:<8}|{name}::{message}' log_format = '{asctime}.{msecs:03.0f}|{levelname:<8}|{name}::{message}'
date_format = '%Y.%m.%d %H.%M.%S' date_format = '%Y.%m.%d %H.%M.%S'
@ -55,20 +57,20 @@ class Geeksbot(commands.Bot):
self.infected = {} self.infected = {}
self.TOKEN = self.bot_secrets['token'] self.TOKEN = self.bot_secrets['token']
del self.bot_secrets['token'] del self.bot_secrets['token']
self.con = Postgres(f" host={self.bot_secrets['db_con']['host']}\ self.db_con = asyncpg.connect(f"host={self.bot_secrets['db_con']['host']}\
port={self.bot_secrets['db_con']['port']}\ database={self.bot_secrets['db_con']['db_name']}\
dbname={self.bot_secrets['db_con']['db_name']}\ user={self.bot_secrets['db_con']['user']}\
connect_timeout=10 user={self.bot_secrets['db_con']['user']}\ password={self.bot_secrets['db_con']['password']}")
password={self.bot_secrets['db_con']['password']}")
del self.bot_secrets['db_con'] del self.bot_secrets['db_con']
self.default_prefix = 'g$' self.default_prefix = 'g~'
self.voice_chans = {} self.voice_chans = {}
self.spam_list = {} self.spam_list = {}
self.gcs_service = build('customsearch', 'v1', developerKey=self.bot_secrets['google_search_key']) self.gcs_service = build('customsearch', 'v1', developerKey=self.bot_secrets['google_search_key'])
async def get_custom_prefix(self, bot_inst, message): @staticmethod
return self.con.one('select prefix from guild_config where guild_id = %(id)s', {'id': message.guild.id})\ async def get_custom_prefix(bot_inst, message):
or self.default_prefix return await bot_inst.db_con.fetchval('select prefix from guild_config where guild_id = $1',
message.guild.id) or bot_inst.default_prefix
async def load_ext(self, ctx, mod=None): async def load_ext(self, ctx, mod=None):
self.load_extension('{0}.{1}'.format(extension_dir, mod)) self.load_extension('{0}.{1}'.format(extension_dir, mod))
@ -120,14 +122,14 @@ async def unload(ctx, mod):
async def on_message(ctx): async def on_message(ctx):
if not ctx.author.bot: if not ctx.author.bot:
if ctx.guild: if ctx.guild:
if int(bot.con.one(f"select channel_lockdown from guild_config where guild_id = %(id)s", if int(await bot.db_con.fetchval("select channel_lockdown from guild_config where guild_id = $1",
{'id': ctx.guild.id})): ctx.guild.id)):
if ctx.channel.id in json.loads(bot.con.one(f"select allowed_channels from guild_config " if ctx.channel.id in json.loads(await bot.db_con.fetchval("select allowed_channels from guild_config "
f"where guild_id = %(id)s", "where guild_id = $1",
{'id': ctx.guild.id})): ctx.guild.id)):
await bot.process_commands(ctx) await bot.process_commands(ctx)
elif ctx.channel.id == 418452585683484680: elif ctx.channel.id == 418452585683484680:
prefix = bot.con.one('select prefix from guild_config where guild_id = %(id)s', {'id': ctx.guild.id}) prefix = await bot.db_con.fetchval('select prefix from guild_config where guild_id = $1', ctx.guild.id)
prefix = prefix[0] if prefix else bot.default_prefix prefix = prefix[0] if prefix else bot.default_prefix
ctx.content = f'{prefix}{ctx.content}' ctx.content = f'{prefix}{ctx.content}'
await bot.process_commands(ctx) await bot.process_commands(ctx)
@ -147,12 +149,12 @@ async def on_ready():
for load_item in load_list: for load_item in load_list:
await bot.load_ext(None, f'{load_item}') await bot.load_ext(None, f'{load_item}')
logging.info('Extension Loaded: {0}'.format(load_item)) logging.info('Extension Loaded: {0}'.format(load_item))
logging.info('Done loading, Geeksbot is active.')
with open(f'{config_dir}reboot', 'r') as f: with open(f'{config_dir}reboot', 'r') as f:
reboot = f.readlines() reboot = f.readlines()
if int(reboot[0]) == 1: if int(reboot[0]) == 1:
await bot.get_channel(int(reboot[1])).send('Restart Finished.') await bot.get_channel(int(reboot[1])).send('Restart Finished.')
with open(f'{config_dir}reboot', 'w') as f: with open(f'{config_dir}reboot', 'w') as f:
f.write(f'0') f.write(f'0')
logging.info('Done loading, Geeksbot is active.')
bot.run(bot.TOKEN) bot.run(bot.TOKEN)

Loading…
Cancel
Save