1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-12-24 22:27:28 +00:00

Merge branch 'dev'

This commit is contained in:
Myned 2017-11-08 22:37:54 -05:00
commit 0eb3e75c3d
3 changed files with 50 additions and 39 deletions

View file

@ -637,7 +637,7 @@ class MsG:
@checks.del_ctx()
async def pool_paginator(self, ctx, *args):
def on_reaction(reaction, user):
if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and user is ctx.author:
if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and (user is ctx.author or user.permissions_in(reaction.message.channel).manage_messages):
raise exc.Abort
elif reaction.emoji == '\N{HEAVY BLACK HEART}' and reaction.message.id == paginator.id and user is ctx.author:
raise exc.Save
@ -775,7 +775,7 @@ class MsG:
@checks.is_nsfw()
async def e621_paginator(self, ctx, *args):
def on_reaction(reaction, user):
if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and user is ctx.author:
if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and (user is ctx.author or user.permissions_in(reaction.message.channel).manage_messages):
raise exc.Abort
elif reaction.emoji == '\N{HEAVY BLACK HEART}' and reaction.message.id == paginator.id and user is ctx.author:
raise exc.Save
@ -866,7 +866,8 @@ class MsG:
try:
if c % limit == 0:
await dest.trigger_typing()
posts.update(await self._get_posts(ctx, booru='e621', tags=tags, limit=limit, previous=posts))
temposts, order = await self._get_posts(ctx, booru='e621', tags=tags, limit=limit, previous=posts)
posts.update(temposts)
keys = list(posts.keys())
values = list(posts.values())
@ -929,17 +930,17 @@ class MsG:
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
@e621_paginator.error
async def e621_paginator_error(self, ctx, error):
if isinstance(error, errext.CheckFailure):
await ctx.send('\N{NO ENTRY} {} **is not an NSFW channel**'.format(ctx.channel.mention), delete_after=10)
return await ctx.message.add_reaction('\N{NO ENTRY}')
# @e621_paginator.error
# async def e621_paginator_error(self, ctx, error):
# if isinstance(error, exc.NSFW):
# await ctx.send('\N{NO ENTRY} {} **is not an NSFW channel**'.format(ctx.channel.mention), delete_after=10)
# await ctx.message.add_reaction('\N{NO ENTRY}')
@commands.command(name='e926page', aliases=['e926p', 'e9p', '9p'])
@checks.del_ctx()
async def e926_paginator(self, ctx, *args):
def on_reaction(reaction, user):
if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and user is ctx.author:
if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and (user is ctx.author or user.permissions_in(reaction.message.channel).manage_messages):
raise exc.Abort
elif reaction.emoji == '\N{HEAVY BLACK HEART}' and reaction.message.id == paginator.id and user is ctx.author:
raise exc.Save
@ -1030,7 +1031,8 @@ class MsG:
try:
if c % limit == 0:
await dest.trigger_typing()
posts.update(await self._get_posts(ctx, booru='e926', tags=tags, limit=limit, previous=posts))
temposts, order = await self._get_posts(ctx, booru='e926', tags=tags, limit=limit, previous=posts)
posts.update(temposts)
keys = list(posts.keys())
values = list(posts.values())
@ -1142,11 +1144,11 @@ class MsG:
# tools.command_dict.setdefault(str(ctx.author.id), {}).update(
# {'command': ctx.command, 'args': ctx.args})
@e621.error
async def e621_error(self, ctx, error):
if isinstance(error, errext.CheckFailure):
await ctx.send('\N{NO ENTRY} {} **is not an NSFW channel**'.format(ctx.channel.mention), delete_after=10)
return await ctx.message.add_reaction('\N{NO ENTRY}')
# @e621.error
# async def e621_error(self, ctx, error):
# if isinstance(error, exc.NSFW):
# await ctx.send('\N{NO ENTRY} {} **is not an NSFW channel**'.format(ctx.channel.mention), delete_after=10)
# await ctx.message.add_reaction('\N{NO ENTRY}')
# Searches for and returns images from e926.net given tags when not blacklisted
@commands.command(aliases=['e9', '9'], brief='e926 | SFW', description='e926 | SFW\nTag-based search for e926.net\n\nYou can only search 5 tags and 6 images at once for now.\ne9 [tags...] ([# of images])')

View file

@ -1,3 +1,5 @@
from discord.ext.commands import errors as errext
base = '\N{WARNING SIGN} **An internal error has occurred.** This has been reported to my master. \N{WOLF FACE}'
@ -5,6 +7,10 @@ async def send_error(ctx, error):
await ctx.send('{}\n```\n{}```'.format(base, error))
# class NSFW(errext.CheckFailure):
# pass
class Wrong(Exception):
pass
@ -37,79 +43,79 @@ class GoTo(Exception):
pass
class Exists(Exception):
class Exists(errext.CommandError):
pass
class MissingArgument(Exception):
class MissingArgument(errext.CommandError):
pass
class FavoritesNotFound(Exception):
class FavoritesNotFound(errext.CommandError):
pass
class PostError(Exception):
class PostError(errext.CommandError):
pass
class ImageError(Exception):
class ImageError(errext.CommandError):
pass
class MatchError(Exception):
class MatchError(errext.CommandError):
pass
class TagBlacklisted(Exception):
class TagBlacklisted(errext.CommandError):
pass
class BoundsError(Exception):
class BoundsError(errext.CommandError):
pass
class TagBoundsError(Exception):
class TagBoundsError(errext.CommandError):
pass
class TagExists(Exception):
class TagExists(errext.CommandError):
pass
class TagError(Exception):
class TagError(errext.CommandError):
pass
class FlagError(Exception):
class FlagError(errext.CommandError):
pass
class BlacklistError(Exception):
class BlacklistError(errext.CommandError):
pass
class NotFound(Exception):
class NotFound(errext.CommandError):
pass
class Timeout(Exception):
class Timeout(errext.CommandError):
pass
class InvalidVideoFile(Exception):
class InvalidVideoFile(errext.CommandError):
pass
class MissingAttachment(Exception):
class MissingAttachment(errext.CommandError):
pass
class TooManyAttachments(Exception):
class TooManyAttachments(errext.CommandError):
pass
class CheckFail(Exception):
class CheckFail(errext.CommandError):
pass

View file

@ -9,6 +9,7 @@ from contextlib import suppress
from pprint import pprint
import discord as d
from discord import errors as err
from discord import utils
from discord.ext import commands
from discord.ext.commands import errors as errext
@ -72,7 +73,7 @@ async def on_message(message):
async def on_error(error, *args, **kwargs):
print('\n! ! ! ! !\nE R R O R : {}\n! ! ! ! !\n'.format(error), file=sys.stderr)
tb.print_exc()
await bot.get_user(u.config['owner_id']).send('**ERROR** \N{WARNING SIGN}\n```\n{}```'.format(error))
await bot.get_user(u.config['owner_id']).send('**ERROR** \N{WARNING SIGN}\n```\n{}```'.format(''.join(tb.format_exception(type(error), error, error.__traceback__))))
await bot.get_channel(u.config['info_channel']).send('**ERROR** \N{WARNING SIGN}\n```\n{}```'.format(error))
if u.temp:
channel = bot.get_channel(u.temp['startup_chan'])
@ -86,8 +87,10 @@ async def on_error(error, *args, **kwargs):
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, errext.CheckFailure):
await ctx.send('\N{NO ENTRY} **Insufficient permissions**', delete_after=10)
if isinstance(error, err.NotFound):
pass
elif isinstance(error, errext.CheckFailure):
await ctx.send('**Insufficient permissions**', delete_after=10)
await ctx.message.add_reaction('\N{NO ENTRY}')
elif isinstance(error, errext.CommandNotFound):
print('INVALID COMMAND : {}'.format(error), file=sys.stderr)
@ -96,8 +99,8 @@ 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.name, ctx.guild.name, error))
await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from *@{}* in {}\n```\n{}```'.format(ctx.message.content, ctx.author.name, ctx.guild.name, error))
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_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}')
# u.notify('C O M M A N D E R R O R')