Merge remote-tracking branch 'origin/release-1.0.0' into release-1.0.0

release-1.0.0
DustyP 8 years ago
commit 66cbaffc7a

@ -62,7 +62,7 @@ class Geeksbot(commands.Bot):
self.voice_chans = {}
self.spam_list = {}
self.owner_id = 351794468870946827
self.__version__ = '1.0.0b'
self.__version__ = 'v1.0.0b2'
self.gcs_service = build('customsearch', 'v1', developerKey=self.bot_secrets['google_search_key'])
self.tpe = futures.ThreadPoolExecutor()
self.geo_api = '2d4e419c2be04c8abe91cb5dd1548c72'

@ -147,54 +147,59 @@ class Admin:
@add.command(name='allowed_channels', aliases=['channel', 'ac'])
async def _allowed_channels(self, ctx, *, channels):
"""Allows Admin to restrict what channels Geeksbot is allowed to access
This only takes effect if channel_lockdown is enabled."""
This only takes effect if channel_lockdown is enabled.
If one of the channels passed is not found then it is ignored."""
if ctx.guild:
if await checks.is_admin(self.bot, ctx):
channels = channels.lower().replace(' ', '').split(',')
added = ''
for channel in channels:
chnl = discord.utils.get(ctx.guild.channels, name=channel)
if chnl is None:
await ctx.send(f'{channel} is not a valid text channel in this guild.')
else:
admin_log.info('Chan found')
if await self.bot.db_con.fetchval('select allowed_channels from guild_config '
'where guild_id = $1', ctx.guild.id):
if chnl.id in json.loads(await self.bot.db_con.fetchval('select allowed_channels '
'from guild_config '
'where guild_id = $1',
ctx.guild.id)):
admin_log.info('Chan found in config')
await ctx.send(f'{channel} is already in the list of allowed channels. Skipping...')
else:
admin_log.info('Chan not found in config')
allowed_channels = json.loads(await self.bot.db_con.fetchval('select allowed_channels '
'from guild_config '
'where guild_id = $1',
ctx.guild.id))\
.append(chnl.id)
existing_channels = list()
channels_add = list()
admin_log.info(channels)
allowed_channels = await self.bot.db_con.fetchval('select allowed_channels from guild_config '
'where guild_id = $1', ctx.guild.id)
if allowed_channels == 'null':
allowed_channels = None
channels = [discord.utils.get(ctx.guild.channels, name=channel)
for channel in channels if channel is not None]
if allowed_channels and channels:
allowed_channels = [int(channel) for channel in json.loads(allowed_channels)]
existing_channels = [channel for channel in channels if channel.id in allowed_channels]
channels_add = [channel for channel in channels if channel.id not in allowed_channels]
allowed_channels += [channel.id for channel in channels if channel.id not in allowed_channels]
await self.bot.db_con.execute('update guild_config set allowed_channels = $2 where guild_id = $1',
ctx.guild.id, json.dumps(allowed_channels))
elif channels:
admin_log.info('Config is empty')
allowed_channels = [channel.id for channel in channels]
await self.bot.db_con.execute('update guild_config set allowed_channels = $2 '
'where guild_id = $1', ctx.guild.id, allowed_channels)
added = f'{added}\n{channel}'
'where guild_id = $1', ctx.guild.id,
json.dumps(allowed_channels))
else:
admin_log.info('Chan not found in config')
allowed_channels = [chnl.id]
await self.bot.db_con.execute('update guild_config set allowed_channels = $2 '
'where guild_id = $1', ctx.guild.id, allowed_channels)
added = f'{added}\n{channel}'
if added != '':
await ctx.send(f'The following channels have been added to the allowed channel list: {added}')
await ctx.send('None of those are valid text channels for this guild.')
return
if existing_channels:
channel_str = '\n'.join([str(channel.name) for channel in existing_channels])
await ctx.send(f'The following channels were skipped because they are already in the config:\n'
f'{channel_str}\n')
if channels_add:
channel_str = '\n'.join([str(channel.name) for channel in channels_add])
await ctx.send('The following channels have been added to the allowed channel list:\n'
f'{channel_str}\n')
await ctx.message.add_reaction('')
else:
await ctx.send(f'You are not authorized to run this command.')
else:
await ctx.send('This command must be run from inside a guild.')
@commands.command()
# TODO Fix view_code
@commands.command(hidden=True)
@commands.is_owner()
async def view_code(self, ctx, code_name):
pag = utils.Paginator(self.bot, prefix='```py', suffix='```')
pag.add(inspect.getsource(self.bot.get_command(code_name).callback))
pag.add(inspect.getsource(self.bot.all_commands[code_name].callback))
for page in pag.pages():
await ctx.send(page)

@ -57,7 +57,7 @@ class Fun:
else:
await ctx.send(f'{member.display_name} is not infected...')
@commands.command()
@commands.command(hidden=True)
@commands.is_owner()
async def print_infections(self, ctx):
await ctx.author.send(f'```{self.bot.infected}```')

@ -41,23 +41,21 @@ class Git:
pag.add('\uFFF7\n\uFFF8')
pag.add(await asyncio.wait_for(self.bot.loop.create_task(run_command('git show --stat | '
'sed "s/.*@.*[.].*/ /g"')), 10))
msg = await ctx.send('Starting Book')
book = Book(pag, (msg, ctx.channel, self.bot, ctx.message))
book = Book(pag, (None, ctx.channel, self.bot, ctx.message))
await book.create_book()
@git.command()
@commands.is_owner()
async def status(self, ctx):
pag = Paginator(max_line_length=60, max_lines=30, max_chars=1014)
em = discord.Embed(style='rich',
title=f'Git Pull',
color=embed_color)
em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}')
pag = Paginator(self.bot, max_line_length=44, max_lines=30, embed=True)
pag.set_embed_meta(title='Git Status',
color=self.bot.embed_color,
thumbnail=f'{ctx.guild.me.avatar_url}')
result = await asyncio.wait_for(self.bot.loop.create_task(run_command('git status')), 10)
pag.add(result)
for page in pag.pages():
em.add_field(name='', value=f'{page}')
await ctx.send(embed=em)
book = Book(pag, (None, ctx.channel, self.bot, ctx.message))
await book.create_book()
def setup(bot):

@ -18,10 +18,10 @@ class Patreon:
async def get_patreon_links(self, ctx, target: discord.Member=None):
"""Prints Patreon information for creators on the server."""
if await self.bot.db_con.fetchval('select patreon_enabled from guild_config where guild_id = $1', ctx.guild.id):
patreon_info = await self.bot.db_con.fetchval('select patreon_message,patreon_links from guild_config '
patreon_info = await self.bot.db_con.fetchrow('select patreon_message,patreon_links from guild_config '
'where guild_id = $1', ctx.guild.id)
message = patreon_info[0].replace('\\n', '\n')
patreon_links = json.loads(patreon_info[1])
message = patreon_info['patreon_message'].replace('\\n', '\n')
patreon_links = json.loads(patreon_info['patreon_links'])
for key in patreon_links:
message = message + '\n{0}: {1}'.format(key, patreon_links[key])
if target is None:

@ -254,17 +254,12 @@ class Utils:
if channel:
chan = discord.utils.get(ctx.guild.channels, id=channel)
msg = ''
admin_roles = []
roles = await self.bot.db_con.fetchval(f'select admin_roles,rcon_admin_roles from guild_config '
f'where $1', ctx.guild.id)
f'where guild_id = $1', ctx.guild.id)
request_id = await self.bot.db_con.fetchval(f'select id from admin_requests where '
f'issuing_member_id = $1 and request_time = $2',
ctx.author.id, ctx.message.created_at)
for item in roles:
i = json.loads(item)
for j in i:
if i[j] not in admin_roles:
admin_roles.append(i[j])
admin_roles = json.loads(roles).values()
for role in admin_roles:
msg = '{0} {1}'.format(msg, discord.utils.get(ctx.guild.roles, id=role).mention)
msg += f"New Request ID: {request_id} " \
@ -372,7 +367,7 @@ class Utils:
except ValueError:
await ctx.send(f'{request_id} is not a valid request id.')
else:
request = await self.bot.db_con.fetchval(f'select * from admin_requests where id = $1',
request = await self.bot.db_con.fetchrow(f'select * from admin_requests where id = $1',
request_id)
if request:
if request[3] == ctx.guild.id:
@ -704,7 +699,7 @@ class Utils:
@commands.command(name='help', aliases=['h'])
@commands.cooldown(1, 5, commands.BucketType.user)
async def custom_help(self, ctx, *, command: str=None):
pag = utils.Paginator(self.bot, embed=True, max_line_length=48)
pag = utils.Paginator(self.bot, embed=True, max_line_length=40)
prefixes = await self.bot.get_custom_prefix(self.bot, ctx.message)
if isinstance(prefixes, list):
prefixes = ', '.join(prefixes)

Loading…
Cancel
Save