Compare commits

...
49 Commits
Author SHA1 Message Date
Dustin Pianalto 897c77fee6 moved song 2018-06-18 15:04:00 -08:00
Dustin Pianalto 9c340116eb remove detailed error messages 2018-06-11 19:18:26 -08:00
Dustin Pianalto 52174175ef Add error color to bot instance 2018-06-11 19:11:48 -08:00
Dustin Pianalto 0858fbc7d5 Shortened help strings 2018-06-11 18:50:03 -08:00
Dustin Pianalto 3e75b20c54 Added help strings 2018-06-11 18:31:08 -08:00
Dustin Pianalto 3dc75dabe6 Added help strings 2018-06-11 18:28:00 -08:00
Dustin Pianalto db525d0048 Added help strings 2018-06-11 18:17:04 -08:00
Dustin Pianalto 35ab455a7c added help docstring
adjusted help line length
2018-06-11 17:32:59 -08:00
Dustin Pianalto 66cbaffc7a Merge remote-tracking branch 'origin/release-1.0.0' into release-1.0.0 2018-06-11 10:47:40 -08:00
Dustin Pianalto 71686b4cc2 fixed layout in ping 2018-06-11 10:47:16 -08:00
Dustin Pianalto 7ac58a435c v1.0.0b2 2018-06-11 02:34:24 -08:00
Dustin Pianalto d596db870b fixed bug in admin close 2018-06-11 02:26:41 -08:00
Dustin Pianalto 69109dc3a9 fixed bug in admin new 2018-06-11 02:22:18 -08:00
Dustin Pianalto c4a0398a60 fixed bug in admin new 2018-06-11 02:17:15 -08:00
Dustin Pianalto 90ca2d0fac fixed bug in admin new 2018-06-11 02:15:34 -08:00
Dustin Pianalto 4bf8649950 removed print from patreon 2018-06-11 02:11:08 -08:00
Dustin Pianalto 70545be638 fixed bug in patreon 2018-06-11 02:10:20 -08:00
Dustin Pianalto d56fb072bb test patreon 2018-06-11 02:07:50 -08:00
Dustin Pianalto 49894b2dd7 test patreon 2018-06-11 02:06:29 -08:00
Dustin Pianalto b4a5f83689 test patreon 2018-06-11 02:04:46 -08:00
Dustin Pianalto 63b87bf1c7 fix git status paginator 2018-06-11 02:00:35 -08:00
Dustin Pianalto dd96a9cf90 update git status to new book 2018-06-11 01:59:14 -08:00
Dustin Pianalto 9c281c6d7f hide print_infections 2018-06-11 01:55:14 -08:00
Dustin Pianalto 0c4fd467ff add todo 2018-06-11 01:53:18 -08:00
Dustin Pianalto f11f53ac81 hide view_code 2018-06-11 01:51:02 -08:00
Dustin Pianalto dc51b4e6b6 fixed bug in view_code 2018-06-11 01:50:36 -08:00
Dustin Pianalto 3531459b03 fixed bug in _allowed_channels 2018-06-11 00:37:17 -08:00
Dustin Pianalto 31a245a7db fixed bug in _allowed_channels 2018-06-11 00:20:28 -08:00
Dustin Pianalto 8c7f33c166 fixed bug in _allowed_channels 2018-06-11 00:11:06 -08:00
Dustin Pianalto 512588a34c fixed bug in _allowed_channels 2018-06-10 22:09:03 -08:00
Dustin Pianalto 7c3e9726f9 fixed bug in _allowed_channels 2018-06-10 22:07:18 -08:00
Dustin Pianalto 95c7bcb928 fixed bug in _allowed_channels 2018-06-10 22:04:21 -08:00
Dustin Pianalto 44c8ca1eb5 fixed bug in _allowed_channels 2018-06-10 22:02:42 -08:00
Dustin Pianalto 9d894a4438 fixed bug in _allowed_channels 2018-06-10 22:01:16 -08:00
Dustin Pianalto 2bdbdb9749 fixed bug in _allowed_channels 2018-06-10 21:56:40 -08:00
Dustin Pianalto 9b47aff4b0 fixed bug in _allowed_channels 2018-06-10 21:55:14 -08:00
Dustin Pianalto 54d5be24e8 rewrote _allowed_channels 2018-06-10 21:44:56 -08:00
Dustin Pianalto d616a94709 testing _allowed_channels 2018-06-09 15:18:30 -08:00
Dustin Pianalto f8fe207721 testing _allowed_channels 2018-06-09 15:14:25 -08:00
Dustin Pianalto 2259900dcd fixed bug in _allowed_channels 2018-06-09 15:07:36 -08:00
Dustin Pianalto ec6cd95c9e test allowed_channels 2018-06-09 15:05:26 -08:00
Dustin Pianalto d14de7a964 Fixed bug in _allowed_channels 2018-06-09 14:58:39 -08:00
Dustin Pianalto a77f976562 Fixed bug in _allowed_channels 2018-06-09 14:58:04 -08:00
Dustin Pianalto 687c62dce7 Fixed bug in _allowed_channels 2018-06-09 14:57:15 -08:00
Dustin Pianalto 778e9890ba Fixed bug in _allowed_channels 2018-06-09 14:51:39 -08:00
Dustin Pianalto b46d8dd366 Fixed bug in _allowed_channels 2018-06-09 14:26:28 -08:00
Dustin Pianalto 46c9075397 changed help line length 2018-06-09 14:17:01 -08:00
Dustin Pianalto 677fc9a60e changed help line length 2018-06-09 14:14:15 -08:00
Dustin Pianalto 4c70c67f31 changed help line length 2018-06-09 14:11:19 -08:00
9 changed files with 131 additions and 95 deletions
+5
View File
@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
+4 -3
View File
@@ -44,7 +44,7 @@ emojis: Dict[str, str] = {
class Geeksbot(commands.Bot): class Geeksbot(commands.Bot):
def __init__(self, **kwargs): def __init__(self, **kwargs):
kwargs["command_prefix"] = self.get_custom_prefix kwargs["command_prefix"] = self.get_custom_prefix
self.description = 'I am Geeksbot Dev! Fear me!\n I might just break and take you with me :P' self.description = 'I am Geeksbot! Fear me!'
kwargs['description'] = self.description kwargs['description'] = self.description
super().__init__(**kwargs) super().__init__(**kwargs)
self.aio_session = aiohttp.ClientSession(loop=self.loop) self.aio_session = aiohttp.ClientSession(loop=self.loop)
@@ -56,13 +56,14 @@ class Geeksbot(commands.Bot):
self.infected = {} self.infected = {}
self.TOKEN = self.bot_secrets['token'] self.TOKEN = self.bot_secrets['token']
self.embed_color = discord.Colour.from_rgb(49, 107, 111) self.embed_color = discord.Colour.from_rgb(49, 107, 111)
self.error_color = discord.Colour.from_rgb(142, 29, 31)
del self.bot_secrets['token'] del self.bot_secrets['token']
self.db_con = database.DatabaseConnection(**self.bot_secrets['db_con']) self.db_con = database.DatabaseConnection(**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.owner_id = 351794468870946827 self.owner_id = 351794468870946827
self.__version__ = '1.0.0b' self.__version__ = 'v1.0.0'
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'])
self.tpe = futures.ThreadPoolExecutor() self.tpe = futures.ThreadPoolExecutor()
self.geo_api = '2d4e419c2be04c8abe91cb5dd1548c72' self.geo_api = '2d4e419c2be04c8abe91cb5dd1548c72'
+50 -44
View File
@@ -94,22 +94,22 @@ class Admin:
@commands.group(case_insensitive=True) @commands.group(case_insensitive=True)
async def set(self, ctx): async def set(self, ctx):
"""Run help set for more info""" """Group for setting configuration options"""
pass pass
@commands.group(case_insensitive=True) @commands.group(case_insensitive=True)
async def add(self, ctx): async def add(self, ctx):
"""Run help set for more info""" """Group for adding items to guild config"""
pass pass
@commands.group(case_insensitive=True) @commands.group(case_insensitive=True)
async def remove(self, ctx): async def remove(self, ctx):
"""Run help set for more info""" """Group for removing items from guild config"""
pass pass
@set.command(name='admin_chan', aliases=['ac', 'admin_chat', 'admin chat']) @set.command(name='admin_chan', aliases=['ac', 'admin_chat', 'admin chat'])
async def _admin_channel(self, ctx, channel: discord.TextChannel=None): async def _admin_channel(self, ctx, channel: discord.TextChannel=None):
"""Sets the channel for admin specific notifications""" """Sets the admin notification channel"""
if ctx.guild: if ctx.guild:
if await checks.is_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx):
if channel is not None: if channel is not None:
@@ -119,7 +119,8 @@ class Admin:
@set.command(name='channel_lockdown', aliases=['lockdown', 'restrict_access', 'cl']) @set.command(name='channel_lockdown', aliases=['lockdown', 'restrict_access', 'cl'])
async def _channel_lockdown(self, ctx, config='true'): async def _channel_lockdown(self, ctx, config='true'):
"""Toggles the channel lockdown restricting Geeksbot to only access channels defined in allowed_channels """Toggles the channel lockdown restriction
When this is active Geeksbot can only respond in channels defined in allowed_channels
If you run this before configuring allowed_channels it will tell you to run that command first.""" If you run this before configuring allowed_channels it will tell you to run that command first."""
if ctx.guild: if ctx.guild:
if await checks.is_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx):
@@ -146,62 +147,67 @@ class Admin:
@add.command(name='allowed_channels', aliases=['channel', 'ac']) @add.command(name='allowed_channels', aliases=['channel', 'ac'])
async def _allowed_channels(self, ctx, *, channels): async def _allowed_channels(self, ctx, *, channels):
"""Allows Admin to restrict what channels Geeksbot is allowed to access """Defines channels Geeksbot can respond in
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 ctx.guild:
if await checks.is_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx):
channels = channels.lower().replace(' ', '').split(',') channels = channels.lower().replace(' ', '').split(',')
added = '' existing_channels = list()
for channel in channels: channels_add = list()
chnl = discord.utils.get(ctx.guild.channels, name=channel) admin_log.info(channels)
if chnl is None: allowed_channels = await self.bot.db_con.fetchval('select allowed_channels from guild_config '
await ctx.send(f'{channel} is not a valid text channel in this guild.') 'where guild_id = $1', ctx.guild.id)
else: if allowed_channels == 'null':
admin_log.info('Chan found') allowed_channels = None
if await self.bot.db_con.fetchval('select allowed_channels from guild_config '
'where guild_id = $1', ctx.guild.id): channels = [discord.utils.get(ctx.guild.channels, name=channel)
if chnl.id in json.loads(await self.bot.db_con.fetchval('select allowed_channels ' for channel in channels if channel is not None]
'from guild_config '
'where guild_id = $1', if allowed_channels and channels:
ctx.guild.id)): allowed_channels = [int(channel) for channel in json.loads(allowed_channels)]
admin_log.info('Chan found in config') existing_channels = [channel for channel in channels if channel.id in allowed_channels]
await ctx.send(f'{channel} is already in the list of allowed channels. Skipping...') channels_add = [channel for channel in channels if channel.id not in allowed_channels]
else: allowed_channels += [channel.id for channel in channels if channel.id not in allowed_channels]
admin_log.info('Chan not found in config') await self.bot.db_con.execute('update guild_config set allowed_channels = $2 where guild_id = $1',
allowed_channels = json.loads(await self.bot.db_con.fetchval('select allowed_channels ' ctx.guild.id, json.dumps(allowed_channels))
'from guild_config ' elif channels:
'where guild_id = $1', admin_log.info('Config is empty')
ctx.guild.id))\ allowed_channels = [channel.id for channel in channels]
.append(chnl.id)
await self.bot.db_con.execute('update guild_config set allowed_channels = $2 ' await self.bot.db_con.execute('update guild_config set allowed_channels = $2 '
'where guild_id = $1', ctx.guild.id, allowed_channels) 'where guild_id = $1', ctx.guild.id,
added = f'{added}\n{channel}' json.dumps(allowed_channels))
else: else:
admin_log.info('Chan not found in config') await ctx.send('None of those are valid text channels for this guild.')
allowed_channels = [chnl.id] return
await self.bot.db_con.execute('update guild_config set allowed_channels = $2 '
'where guild_id = $1', ctx.guild.id, allowed_channels) if existing_channels:
added = f'{added}\n{channel}' channel_str = '\n'.join([str(channel.name) for channel in existing_channels])
if added != '': await ctx.send(f'The following channels were skipped because they are already in the config:\n'
await ctx.send(f'The following channels have been added to the allowed channel list: {added}') 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('') await ctx.message.add_reaction('')
else: else:
await ctx.send(f'You are not authorized to run this command.') await ctx.send(f'You are not authorized to run this command.')
else: else:
await ctx.send('This command must be run from inside a guild.') 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() @commands.is_owner()
async def view_code(self, ctx, code_name): async def view_code(self, ctx, code_name):
pag = utils.Paginator(self.bot, prefix='```py', suffix='```') 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(): for page in pag.pages():
await ctx.send(page) await ctx.send(page)
@add.command(aliases=['prefix', 'p']) @add.command(aliases=['prefix', 'p'])
@commands.cooldown(1, 5, type=commands.BucketType.guild) @commands.cooldown(1, 5, type=commands.BucketType.guild)
async def add_prefix(self, ctx, *, prefix=None): async def add_prefix(self, ctx, *, prefix=None):
"""Adds a guild specific prefix to the guild config """Adds a custom prefix for the current guild
Note: This overwrites the default of g$. If you would Note: This overwrites the default of g$. If you would
like to keep using g$ you will need to add it to the like to keep using g$ you will need to add it to the
Guild config as well.""" Guild config as well."""
@@ -234,7 +240,7 @@ class Admin:
@remove.command(aliases=['prefix', 'p']) @remove.command(aliases=['prefix', 'p'])
@commands.cooldown(1, 5, type=commands.BucketType.guild) @commands.cooldown(1, 5, type=commands.BucketType.guild)
async def remove_prefix(self, ctx, *, prefix=None): async def remove_prefix(self, ctx, *, prefix=None):
"""Removes a guild specific prefix from the guild config """Removes custom prefix from the current guild
If the last prefix is removed then Geeksbot will default If the last prefix is removed then Geeksbot will default
Back to g$""" Back to g$"""
if ctx.guild: if ctx.guild:
@@ -273,7 +279,7 @@ class Admin:
@commands.cooldown(1, 5, type=commands.BucketType.guild) @commands.cooldown(1, 5, type=commands.BucketType.guild)
@commands.check(checks.is_guild_owner) @commands.check(checks.is_guild_owner)
async def _add_admin_role(self, ctx, role=None): async def _add_admin_role(self, ctx, role=None):
"""The Guild owner can add a role to the admin list """Adds role to the admin list for current guild
Allowing members of that role to run admin commands Allowing members of that role to run admin commands
on the current guild.""" on the current guild."""
role = discord.utils.get(ctx.guild.roles, name=role) role = discord.utils.get(ctx.guild.roles, name=role)
@@ -294,7 +300,7 @@ class Admin:
@commands.cooldown(1, 5, type=commands.BucketType.guild) @commands.cooldown(1, 5, type=commands.BucketType.guild)
@commands.check(checks.is_guild_owner) @commands.check(checks.is_guild_owner)
async def _remove_admin_role(self, ctx, role=None): async def _remove_admin_role(self, ctx, role=None):
"""The Guild owner can remove a role from the admin list""" """Removes role from admin list in current guild"""
role = discord.utils.get(ctx.guild.roles, name=role) role = discord.utils.get(ctx.guild.roles, name=role)
if role is not None: if role is not None:
roles = json.loads(await self.bot.db_con.fetchval('select admin_roles from guild_config ' roles = json.loads(await self.bot.db_con.fetchval('select admin_roles from guild_config '
+7 -7
View File
@@ -150,13 +150,13 @@ class BotEvents:
# noinspection PyMethodMayBeStatic # noinspection PyMethodMayBeStatic
async def on_command_error(self, ctx, error): async def on_command_error(self, ctx, error):
pag = utils.Paginator(ctx.bot) pag = utils.Paginator(ctx.bot, embed=True, max_line_length=48)
import traceback pag.set_embed_meta(title=f'Command Error',
if ctx.channel.id == 418452585683484680 and type(error) == commands.errors.CommandNotFound: color=self.bot.error_color,
return thumbnail=f'{ctx.guild.me.avatar_url}')
pag.add(''.join(traceback.format_exception(type(error), error, error.__traceback__))) pag.add(error)
for page in pag.pages(): book = utils.Book(pag, (None, ctx.channel, self.bot, ctx.message))
await ctx.send(page) await book.create_book()
async def on_guild_join(self, guild): async def on_guild_join(self, guild):
with open(f"{config_dir}{default_guild_config_file}", 'r') as file: with open(f"{config_dir}{default_guild_config_file}", 'r') as file:
+8 -1
View File
@@ -33,6 +33,9 @@ class Fun:
@commands.command() @commands.command()
@commands.cooldown(1, 30, type=commands.BucketType.user) @commands.cooldown(1, 30, type=commands.BucketType.user)
async def infect(self, ctx, member: discord.Member, emoji): async def infect(self, ctx, member: discord.Member, emoji):
"""Infects a user with the given emoji
Every time the user sends a message that I am also in I will react to that message with said emoji."""
if member.id == self.bot.user.id and ctx.author.id != owner_id: if member.id == self.bot.user.id and ctx.author.id != owner_id:
await ctx.send(f'You rolled a Critical Fail...\nInfection bounces off and rebounds on the attacker.') await ctx.send(f'You rolled a Critical Fail...\nInfection bounces off and rebounds on the attacker.')
member = ctx.author member = ctx.author
@@ -48,6 +51,7 @@ class Fun:
@commands.command() @commands.command()
@commands.cooldown(1, 5, type=commands.BucketType.user) @commands.cooldown(1, 5, type=commands.BucketType.user)
async def heal(self, ctx, member: discord.Member): async def heal(self, ctx, member: discord.Member):
"""Removes infection from user."""
if ctx.author == member and ctx.author.id != owner_id: if ctx.author == member and ctx.author.id != owner_id:
await ctx.send('You can\'t heal yourself silly...') await ctx.send('You can\'t heal yourself silly...')
else: else:
@@ -57,7 +61,7 @@ class Fun:
else: else:
await ctx.send(f'{member.display_name} is not infected...') await ctx.send(f'{member.display_name} is not infected...')
@commands.command() @commands.command(hidden=True)
@commands.is_owner() @commands.is_owner()
async def print_infections(self, ctx): async def print_infections(self, ctx):
await ctx.author.send(f'```{self.bot.infected}```') await ctx.author.send(f'```{self.bot.infected}```')
@@ -65,6 +69,7 @@ class Fun:
@commands.command() @commands.command()
@commands.cooldown(1, 5, type=commands.BucketType.user) @commands.cooldown(1, 5, type=commands.BucketType.user)
async def slap(self, ctx, member: discord.Member): async def slap(self, ctx, member: discord.Member):
"""IRC Style Trout Slap"""
trout = await self.bot.db_con.fetchval("select code from geeksbot_emojis where id = 449083238766477312") trout = await self.bot.db_con.fetchval("select code from geeksbot_emojis where id = 449083238766477312")
if member.id == self.bot.user.id and ctx.author.id != owner_id: if member.id == self.bot.user.id and ctx.author.id != owner_id:
await ctx.send(f'You rolled a Critical Fail...\nThe trout bounces off and rebounds on the attacker.') await ctx.send(f'You rolled a Critical Fail...\nThe trout bounces off and rebounds on the attacker.')
@@ -84,6 +89,7 @@ class Fun:
@commands.command() @commands.command()
@commands.cooldown(1, 5, type=commands.BucketType.user) @commands.cooldown(1, 5, type=commands.BucketType.user)
async def fact(self, ctx, number: int): async def fact(self, ctx, number: int):
"""Returns the given factorial up to 20,000!"""
if 0 < number < 20001: if 0 < number < 20001:
n = 1990 n = 1990
with ctx.channel.typing(): with ctx.channel.typing():
@@ -150,6 +156,7 @@ class Fun:
@commands.command(name='explode', aliases=['splode']) @commands.command(name='explode', aliases=['splode'])
async def explode_user(self, ctx, member: discord.Member=None): async def explode_user(self, ctx, member: discord.Member=None):
"""Trolls user by punching them to oblivion."""
if member is None or member.id == 396588996706304010: if member is None or member.id == 396588996706304010:
member = ctx.author member = ctx.author
+11 -11
View File
@@ -16,7 +16,7 @@ class Git:
@commands.group(case_insensitive=True, invoke_without_command=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""" """Shows my Git link"""
em = discord.Embed(style='rich', em = discord.Embed(style='rich',
title=f'Here is where you can find my code', title=f'Here is where you can find my code',
url='https://github.com/dustinpianalto/Geeksbot/tree/development', url='https://github.com/dustinpianalto/Geeksbot/tree/development',
@@ -29,6 +29,7 @@ class Git:
@git.command() @git.command()
@commands.is_owner() @commands.is_owner()
async def pull(self, ctx): async def pull(self, ctx):
"""Pulls updates from GitHub rebasing branch."""
pag = Paginator(self.bot, max_line_length=44, embed=True) pag = Paginator(self.bot, max_line_length=44, embed=True)
pag.set_embed_meta(title='Git Pull', pag.set_embed_meta(title='Git Pull',
color=self.bot.embed_color, color=self.bot.embed_color,
@@ -41,23 +42,22 @@ class Git:
pag.add('\uFFF7\n\uFFF8') pag.add('\uFFF7\n\uFFF8')
pag.add(await asyncio.wait_for(self.bot.loop.create_task(run_command('git show --stat | ' pag.add(await asyncio.wait_for(self.bot.loop.create_task(run_command('git show --stat | '
'sed "s/.*@.*[.].*/ /g"')), 10)) 'sed "s/.*@.*[.].*/ /g"')), 10))
msg = await ctx.send('Starting Book') book = Book(pag, (None, ctx.channel, self.bot, ctx.message))
book = Book(pag, (msg, ctx.channel, self.bot, ctx.message))
await book.create_book() await book.create_book()
@git.command() @git.command()
@commands.is_owner() @commands.is_owner()
async def status(self, ctx): async def status(self, ctx):
pag = Paginator(max_line_length=60, max_lines=30, max_chars=1014) """Gets status of current branch."""
em = discord.Embed(style='rich', pag = Paginator(self.bot, max_line_length=44, max_lines=30, embed=True)
title=f'Git Pull', pag.set_embed_meta(title='Git Status',
color=embed_color) color=self.bot.embed_color,
em.set_thumbnail(url=f'{ctx.guild.me.avatar_url}') thumbnail=f'{ctx.guild.me.avatar_url}')
result = await asyncio.wait_for(self.bot.loop.create_task(run_command('git status')), 10) result = await asyncio.wait_for(self.bot.loop.create_task(run_command('git status')), 10)
pag.add(result) pag.add(result)
for page in pag.pages(): book = Book(pag, (None, ctx.channel, self.bot, ctx.message))
em.add_field(name='', value=f'{page}') await book.create_book()
await ctx.send(embed=em)
def setup(bot): def setup(bot):
+3 -3
View File
@@ -18,10 +18,10 @@ class Patreon:
async def get_patreon_links(self, ctx, target: discord.Member=None): async def get_patreon_links(self, ctx, target: discord.Member=None):
"""Prints Patreon information for creators on the server.""" """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): 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) 'where guild_id = $1', ctx.guild.id)
message = patreon_info[0].replace('\\n', '\n') message = patreon_info['patreon_message'].replace('\\n', '\n')
patreon_links = json.loads(patreon_info[1]) patreon_links = json.loads(patreon_info['patreon_links'])
for key in patreon_links: for key in patreon_links:
message = message + '\n{0}: {1}'.format(key, patreon_links[key]) message = message + '\n{0}: {1}'.format(key, patreon_links[key])
if target is None: if target is None:
+40 -23
View File
@@ -54,15 +54,15 @@ class Utils:
msg = await self.bot.wait_for('message', timeout=5, check=check) msg = await self.bot.wait_for('message', timeout=5, check=check)
self.bot.ping_times[i]['rec'] = msg self.bot.ping_times[i]['rec'] = msg
@commands.command() @commands.command(hidden=True)
async def channel_ping(self, ctx, wait_time: float=10, message: str='=bump', channel: int=265828729970753537): async def channel_ping(self, ctx, wait_time: float=10, message: str='=bump', channel: int=265828729970753537):
await ctx.send('Starting Background Process.') await ctx.send('Starting Background Process.')
self.bot.loop.create_task(self._4_hour_ping(channel, message, wait_time)) self.bot.loop.create_task(self._4_hour_ping(channel, message, wait_time))
@commands.command() @commands.command(hidden=True)
@commands.is_owner() @commands.is_owner()
async def sysinfo(self, ctx): async def sysinfo(self, ctx):
"""WIP Gets current system status for the server that Geeksbot is running on.""" """Gets system status for my server."""
await ctx.send(f'```ml\n' await ctx.send(f'```ml\n'
f'CPU Percentages: {psutil.cpu_percent(percpu=True)}\n' f'CPU Percentages: {psutil.cpu_percent(percpu=True)}\n'
f'Memory Usage: {psutil.virtual_memory().percent}%\n' f'Memory Usage: {psutil.virtual_memory().percent}%\n'
@@ -178,7 +178,10 @@ class Utils:
@commands.command() @commands.command()
@commands.cooldown(1, 5, type=commands.BucketType.user) @commands.cooldown(1, 5, type=commands.BucketType.user)
async def ping(self, ctx, mode='normal', count: int=2): async def ping(self, ctx, mode='normal', count: int=2):
"""Check the Bot\'s connection to Discord""" """Check the Bot\'s connection to Discord
For more detailed information set the <mode> as comp and it will test the ping
<count> number of times."""
em = discord.Embed(style='rich', em = discord.Embed(style='rich',
title=f'Pong 🏓', title=f'Pong 🏓',
color=discord.Colour.green() color=discord.Colour.green()
@@ -186,8 +189,8 @@ class Utils:
msg = await ctx.send(embed=em) msg = await ctx.send(embed=em)
time1 = ctx.message.created_at time1 = ctx.message.created_at
time = (msg.created_at - time1).total_seconds() * 1000 time = (msg.created_at - time1).total_seconds() * 1000
em.description = f'''Response Time: **{math.ceil(time)}ms** em.description = f'Response Time: **{math.ceil(time)}ms**\n' \
Discord Latency: **{math.ceil(self.bot.latency*1000)}ms**''' f'Discord Latency: **{math.ceil(self.bot.latency*1000)}ms**'
await msg.edit(embed=em) await msg.edit(embed=em)
if mode == 'comp': if mode == 'comp':
@@ -216,8 +219,8 @@ class Utils:
time = time.total_seconds() time = time.total_seconds()
times.append(time) times.append(time)
value = f"Message Sent:" \ value = f"Message Sent:" \
f"{datetime.strftime(self.bot.ping_times[i]['snd'].created_at, '%H:%M:%S.%f')}" \ f"{datetime.strftime(self.bot.ping_times[i]['snd'].created_at, '%H:%M:%S.%f')}\n" \
f"Response Received: {datetime.strftime(now, '%H:%M:%S.%f')}" \ f"Response Received: {datetime.strftime(now, '%H:%M:%S.%f')}\n" \
f"Total Time: {math.ceil(time * 1000)}ms" f"Total Time: {math.ceil(time * 1000)}ms"
await self.bot.ping_times[i]['rec'].delete() await self.bot.ping_times[i]['rec'].delete()
em.add_field(name=f'Ping Test {i}', value=value, inline=True) em.add_field(name=f'Ping Test {i}', value=value, inline=True)
@@ -234,7 +237,7 @@ class Utils:
@commands.group(case_insensitive=True) @commands.group(case_insensitive=True)
async def admin(self, ctx): async def admin(self, ctx):
"""Run help admin for more info""" """Group for Admin help requests"""
pass pass
@admin.command(name='new', aliases=['nr']) @admin.command(name='new', aliases=['nr'])
@@ -254,17 +257,12 @@ class Utils:
if channel: if channel:
chan = discord.utils.get(ctx.guild.channels, id=channel) chan = discord.utils.get(ctx.guild.channels, id=channel)
msg = '' msg = ''
admin_roles = []
roles = await self.bot.db_con.fetchval(f'select admin_roles,rcon_admin_roles from guild_config ' 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 ' request_id = await self.bot.db_con.fetchval(f'select id from admin_requests where '
f'issuing_member_id = $1 and request_time = $2', f'issuing_member_id = $1 and request_time = $2',
ctx.author.id, ctx.message.created_at) ctx.author.id, ctx.message.created_at)
for item in roles: admin_roles = json.loads(roles).values()
i = json.loads(item)
for j in i:
if i[j] not in admin_roles:
admin_roles.append(i[j])
for role in admin_roles: for role in admin_roles:
msg = '{0} {1}'.format(msg, discord.utils.get(ctx.guild.roles, id=role).mention) msg = '{0} {1}'.format(msg, discord.utils.get(ctx.guild.roles, id=role).mention)
msg += f"New Request ID: {request_id} " \ msg += f"New Request ID: {request_id} " \
@@ -283,7 +281,7 @@ class Utils:
@admin.command(name='list', aliases=['lr']) @admin.command(name='list', aliases=['lr'])
@commands.cooldown(1, 5, type=commands.BucketType.user) @commands.cooldown(1, 5, type=commands.BucketType.user)
async def list_admin_requests(self, ctx, assigned_to: discord.Member=None): async def list_admin_requests(self, ctx, assigned_to: discord.Member=None):
"""Returns a list of all active Admin help requests for this guild """List of all active Admin help requests
If a user runs this command it will return all the requests that they have submitted and are still open. If a user runs this command it will return all the requests that they have submitted and are still open.
- The [assigned_to] argument is ignored but will still give an error if an incorrect value is entered. - The [assigned_to] argument is ignored but will still give an error if an incorrect value is entered.
@@ -372,7 +370,7 @@ class Utils:
except ValueError: except ValueError:
await ctx.send(f'{request_id} is not a valid request id.') await ctx.send(f'{request_id} is not a valid request id.')
else: 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) request_id)
if request: if request:
if request[3] == ctx.guild.id: if request[3] == ctx.guild.id:
@@ -396,7 +394,8 @@ class Utils:
@commands.command(name='weather', aliases=['wu']) @commands.command(name='weather', aliases=['wu'])
@commands.cooldown(5, 15, type=commands.BucketType.default) @commands.cooldown(5, 15, type=commands.BucketType.default)
async def get_weather(self, ctx, *, location='palmer ak'): async def get_weather(self, ctx, *, location='palmer ak'):
"""Gets the weather data for the location provided, """Gets the weather data for the location given
If no location is included then it will get the weather for the Bot's home location. If no location is included then it will get the weather for the Bot's home location.
""" """
try: try:
@@ -433,7 +432,8 @@ class Utils:
@commands.command(name='localtime', aliases=['time', 'lt']) @commands.command(name='localtime', aliases=['time', 'lt'])
@commands.cooldown(1, 3, type=commands.BucketType.user) @commands.cooldown(1, 3, type=commands.BucketType.user)
async def get_localtime(self, ctx, timezone: str='Anchorage'): async def get_localtime(self, ctx, timezone: str='Anchorage'):
"""Shows the current time localized to the timezone given """Shows the current time in the timezone given
This defaults to the Bot's local timezone of Anchorage Alaska USA if none are given.""" This defaults to the Bot's local timezone of Anchorage Alaska USA if none are given."""
em = discord.Embed() em = discord.Embed()
@@ -462,6 +462,13 @@ class Utils:
@commands.command(name='gettimein', aliases=['timein', 'gti']) @commands.command(name='gettimein', aliases=['timein', 'gti'])
@commands.cooldown(1, 3, type=commands.BucketType.user) @commands.cooldown(1, 3, type=commands.BucketType.user)
async def get_time_in_timezone(self, ctx, timezone: str='US/Eastern', *, time: str=None): async def get_time_in_timezone(self, ctx, timezone: str='US/Eastern', *, time: str=None):
"""Convert the time provided to given timezone
Attempts to process the given time and timezone and convert into the given timezone.
Example: g$gti CET Friday June 15 2018 US/Alaska
This will be processed into a datetime with US/Alaska set as the timezone and will
convert it into CET timezone and return both times."""
em = discord.Embed() em = discord.Embed()
if time is None: if time is None:
@@ -521,7 +528,7 @@ class Utils:
@commands.command(name='purge', aliases=['clean', 'erase']) @commands.command(name='purge', aliases=['clean', 'erase'])
@commands.cooldown(1, 3, type=commands.BucketType.user) @commands.cooldown(1, 3, type=commands.BucketType.user)
async def purge_messages(self, ctx, number: int=20, member: discord.Member=None): async def purge_messages(self, ctx, number: int=20, member: discord.Member=None):
"""Gives Admin the ability to quickly clear messages from a channel """Purge messages from the current channel
By default this will only purge messages sent by Geeksbot and any messages that appear to By default this will only purge messages sent by Geeksbot and any messages that appear to
have called Geeksbot (aka start with one of the Geeksbot's prefixes for this Guild) have called Geeksbot (aka start with one of the Geeksbot's prefixes for this Guild)
If you want to purge messages from a different user you must provide a number and member If you want to purge messages from a different user you must provide a number and member
@@ -565,7 +572,9 @@ class Utils:
@commands.command(name='purge_all', aliases=['cls', 'clear']) @commands.command(name='purge_all', aliases=['cls', 'clear'])
@commands.cooldown(1, 3, type=commands.BucketType.user) @commands.cooldown(1, 3, type=commands.BucketType.user)
async def purge_all(self, ctx, number: int=20, contents: str='all'): async def purge_all(self, ctx, number: int=20, contents: str='all'):
"""Will delete all of the last <number> of messages from the channel """Purge all messages from the current channel
Will delete all of the last <number> of messages from the channel
If <contents> is not 'all' then only messages containing <contents> If <contents> is not 'all' then only messages containing <contents>
will be deleted.""" will be deleted."""
if await checks.is_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx):
@@ -596,6 +605,8 @@ class Utils:
@commands.command(hidden=True, name='sheets') @commands.command(hidden=True, name='sheets')
async def google_sheets(self, ctx, member: discord.Member): async def google_sheets(self, ctx, member: discord.Member):
"""Access Google Sheets and looks for the member"""
if await checks.is_admin(self.bot, ctx): if await checks.is_admin(self.bot, ctx):
scope = ['https://spreadsheets.google.com/feeds', scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive'] 'https://www.googleapis.com/auth/drive']
@@ -621,7 +632,10 @@ class Utils:
@commands.command(name='iss') @commands.command(name='iss')
async def iss_loc(self, ctx): async def iss_loc(self, ctx):
"""WIP Locates the International Space Station and display on a map""" """Locate the International Space Station
Gets the location of the ISS and display on a
Blue Marble map."""
def gen_image(iss_loc): def gen_image(iss_loc):
lat = iss_loc['latitude'] lat = iss_loc['latitude']
lon = iss_loc['longitude'] lon = iss_loc['longitude']
@@ -646,6 +660,8 @@ class Utils:
@commands.command(name='location', aliases=['loc', 'map']) @commands.command(name='location', aliases=['loc', 'map'])
async def map_location(self, ctx, *, location): async def map_location(self, ctx, *, location):
"""WIP Displays the given location on a map """WIP Displays the given location on a map
Searches for the location provided and plots the Lat Long on a map.
Note: This is SLOW!!! Be prepared to wait up to a minute for the result""" Note: This is SLOW!!! Be prepared to wait up to a minute for the result"""
def draw_map(m, scale=1): def draw_map(m, scale=1):
@@ -704,6 +720,7 @@ class Utils:
@commands.command(name='help', aliases=['h']) @commands.command(name='help', aliases=['h'])
@commands.cooldown(1, 5, commands.BucketType.user) @commands.cooldown(1, 5, commands.BucketType.user)
async def custom_help(self, ctx, *, command: str=None): async def custom_help(self, ctx, *, command: str=None):
"""This help message"""
pag = utils.Paginator(self.bot, embed=True, max_line_length=48) pag = utils.Paginator(self.bot, embed=True, max_line_length=48)
prefixes = await self.bot.get_custom_prefix(self.bot, ctx.message) prefixes = await self.bot.get_custom_prefix(self.bot, ctx.message)
if isinstance(prefixes, list): if isinstance(prefixes, list):