From 000e7a86e77d3214412082d394389231d22650e8 Mon Sep 17 00:00:00 2001 From: Myned Date: Fri, 1 Dec 2017 18:05:11 -0500 Subject: [PATCH 1/5] WIP periodic posting cog --- src/main/cogs/periodic.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/cogs/periodic.py diff --git a/src/main/cogs/periodic.py b/src/main/cogs/periodic.py new file mode 100644 index 0000000..f1dcb1e --- /dev/null +++ b/src/main/cogs/periodic.py @@ -0,0 +1,18 @@ +import asyncio +import json +from datetime import datetime as dt + +import discord as d +from discord import errors as err +from discord.ext import commands as cmds +from discord.ext.commands import errors as errext + +from misc import exceptions as exc +from misc import checks +from utils import utils as u + + +class Post: + + def __init__(self, bot): + self.bot = bot From b47bedaf5b63a7629d812993dc3193c2eac7fc2a Mon Sep 17 00:00:00 2001 From: Myned Date: Fri, 1 Dec 2017 18:05:33 -0500 Subject: [PATCH 2/5] Fixed secondary test command visible to endusers --- src/main/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/run.py b/src/main/run.py index 6130920..0353cf9 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -60,7 +60,7 @@ def get_prefix(bot, message): bot = cmds.Bot(command_prefix=get_prefix, formatter=cmds.HelpFormatter(show_check_failure=True), description='Modumind - A booru bot with a side of management\n\nS for single command\nG for group command', help_attrs={'aliases': ['h']}, pm_help=None) -@bot.command(help='help', brief='brief', description='description', usage='usage') +@bot.command(help='help', brief='brief', description='description', usage='usage', hidden=True) async def test(ctx): pass From 0cc8bdcf80936fa402096e10ee5d1fed2fa34999 Mon Sep 17 00:00:00 2001 From: Myned Date: Fri, 1 Dec 2017 18:05:44 -0500 Subject: [PATCH 3/5] Whitespace --- src/main/run.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/run.py b/src/main/run.py index 0353cf9..a7cdc59 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -85,6 +85,7 @@ async def on_ready(): print('\n> > > > > > > > >\nC O N N E C T E D : {}\n> > > > > > > > >\n'.format(bot.user.name)) await bot.get_channel(u.config['info_channel']).send('**Started** \N{BLACK SUN WITH RAYS} .') # u.notify('C O N N E C T E D') + if u.temp['startup']: with suppress(err.NotFound): if u.temp['startup'][0] == 'guild': From 8c15767da8d46e51260dc0a0eba0b90904f3c9b6 Mon Sep 17 00:00:00 2001 From: Myned Date: Fri, 1 Dec 2017 18:06:40 -0500 Subject: [PATCH 4/5] Temp limited error logging to 1500 characters if over that --- src/main/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/run.py b/src/main/run.py index a7cdc59..25c4367 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -144,7 +144,7 @@ async def on_command_error(ctx, error): print('\n! ! ! ! ! ! ! ! ! ! ! !\nC O M M A N D E R R O R : {}\n! ! ! ! ! ! ! ! ! ! ! !\n'.format( error), file=sys.stderr) tb.print_exception(type(error), error, error.__traceback__, file=sys.stderr) - await bot.get_user(u.config['owner_id']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.mention, ctx.channel.mention, ''.join(tb.format_exception(type(error), error, error.__traceback__)))) + await bot.get_user(u.config['owner_id']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.mention, ctx.channel.mention, ''.join(tb.format_exception(type(error), error, error.__traceback__ if len(error.__traceback__) < 1500 else error.__traceback__[:1500])))) await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.mention, ctx.channel.mention, error)) await exc.send_error(ctx, error) await ctx.message.add_reaction('\N{WARNING SIGN}') From e6a098c2116d598b8d5d56c15eadbc754090dafd Mon Sep 17 00:00:00 2001 From: Myned Date: Fri, 1 Dec 2017 18:07:48 -0500 Subject: [PATCH 5/5] WIP selfbot config option --- src/main/run.py | 10 +++++++--- src/main/utils/utils.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/run.py b/src/main/run.py index 25c4367..8e3d0de 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -102,8 +102,12 @@ async def on_ready(): @bot.event async def on_message(message): - if message.author is not bot.user and not message.author.bot: - await bot.process_commands(message) + if u.config['selfbot'] == 'False': + if message.author is not bot.user and not message.author.bot: + await bot.process_commands(message) + else: + if not message.author.bot: + await bot.process_commands(message) @bot.event @@ -162,7 +166,7 @@ async def on_command_completion(ctx): for command in ('lastcommand', ',restart', ',die'): if ctx.command.name == command: return - + u.last_commands[ctx.author.id] = ctx @bot.event diff --git a/src/main/utils/utils.py b/src/main/utils/utils.py index 12324a8..4a08229 100644 --- a/src/main/utils/utils.py +++ b/src/main/utils/utils.py @@ -30,7 +30,7 @@ try: except FileNotFoundError: with open('config.json', 'w') as outfile: jsn.dump({'client_id': 0, 'info_channel': 0, 'owner_id': 0, 'permissions': 126016, - 'playing': 'a game', 'prefix': [',', 'm,'], 'token': 'str'}, outfile, indent=4, sort_keys=True) + 'playing': 'a game', 'prefix': [',', 'm,'], 'selfbot': 'False', 'token': 'str'}, outfile, indent=4, sort_keys=True) raise FileNotFoundError( 'FILE NOT FOUND : config.json created with abstract values. Restart run.py with correct values')