1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-01 21:02:38 +00:00

4 space > 2 space

This commit is contained in:
Myned 2017-10-17 19:04:45 -04:00
parent f4da3c6705
commit 6f38e0bc8e
11 changed files with 1792 additions and 1793 deletions

View file

@ -24,6 +24,7 @@ class MsG:
self.color = d.Color(0x1A1A1A)
self.LIMIT = 100
self.RATE_LIMIT = u.RATE_LIMIT
self.HISTORY_LIMIT = 99
self.queue = asyncio.Queue()
self.qualitifying = False
@ -83,9 +84,9 @@ class MsG:
@commands.command(name='getimage', aliases=['geti', 'gi'])
@checks.del_ctx()
async def get_image(self, ctx, *args):
try:
dest, urls = u.get_args(ctx, args, rem=True)
try:
if not urls:
raise exc.MissingArgument
@ -108,10 +109,10 @@ class MsG:
@commands.command(name='reverse', aliases=['rev', 'ris'], brief='e621 Reverse image search', description='e621 | NSFW\nReverse-search an image with given URL')
@checks.del_ctx()
async def reverse_image_search(self, ctx, *args):
try:
dest, urls = u.get_args(ctx, args, rem=True)
c = 0
try:
if not urls and not ctx.message.attachments:
raise exc.MissingArgument
@ -151,10 +152,10 @@ class MsG:
@commands.command(name='quality', aliases=['qual', 'qrev', 'qis'])
@checks.del_ctx()
async def quality_reverse_image_search(self, ctx, *args):
try:
dest, urls = u.get_args(ctx, args, rem=True)
c = 0
try:
if not urls and not ctx.message.attachments:
raise exc.MissingArgument
@ -198,16 +199,14 @@ class MsG:
@commands.command(name='reversify', aliases=['revify', 'risify', 'rify'])
@checks.del_ctx()
async def reversify(self, ctx, *args):
dest, limit, remove = u.get_args(ctx, args, rem=True, rm=True)
try:
dest, remove, limit = u.get_args(ctx, args, rm=True, lim=self.HISTORY_LIMIT)
urls = []
attachments = []
if not ctx.author.permissions_in(ctx.channel).manage_messages:
dest = ctx.author
try:
limit = int(limit)
async for message in ctx.channel.history(limit=limit + 1):
if message.author.id != self.bot.user.id and re.search('(http[a-z]?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) is not None:
urls.append(message)
@ -267,16 +266,14 @@ class MsG:
@commands.command(name='qualitify', aliases=['qualify', 'qrevify', 'qrisify', 'qify'])
@checks.del_ctx()
async def qualitify(self, ctx, *args):
dest, limit, remove = u.get_args(ctx, args, rem=True, rm=True)
try:
dest, remove, limit = u.get_args(ctx, args, rm=True, lim=self.HISTORY_LIMIT)
urls = []
attachments = []
if not ctx.author.permissions_in(ctx.channel).manage_messages:
dest = ctx.author
try:
limit = int(limit)
async for message in ctx.channel.history(limit=limit + 1):
if message.author.id != self.bot.user.id and re.search('(http[a-z]?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) is not None:
urls.append(message)
@ -498,11 +495,11 @@ class MsG:
return True
return False
try:
dest, query = u.get_args(ctx, args, rem=True)
starred = []
c = 1
try:
await dest.trigger_typing()
pool, posts = await self.return_pool(ctx, booru='e621', query=query)
@ -678,12 +675,12 @@ class MsG:
return True
return False
try:
dest, tags = u.get_args(ctx, args, rem=True)
limit = self.LIMIT / 5
starred = []
c = 1
try:
tags = self.get_favorites(ctx, tags)
await ctx.trigger_typing()
@ -816,9 +813,9 @@ class MsG:
@checks.del_ctx()
@checks.is_nsfw()
async def e621(self, ctx, *args):
dest, args, limit = u.get_args(ctx, args, rem=True, lim=True)
try:
dest, args, limit = u.get_args(ctx, args, rem=True, lim=3)
tags = self.get_favorites(ctx, args)
await dest.trigger_typing()
@ -869,9 +866,9 @@ class MsG:
@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])')
@checks.del_ctx()
async def e926(self, ctx, *args):
dest, args, limit = u.get_args(ctx, args, rem=True, lim=True)
try:
dest, args, limit = u.get_args(ctx, args, rem=True, lim=3)
tags = self.get_favorites(ctx, args)
await dest.trigger_typing()
@ -941,9 +938,9 @@ class MsG:
@_add_favorite.command(name='tags', aliases=['t'])
async def __add_favorite_tags(self, ctx, *args):
try:
dest, tags = u.get_args(ctx, args, rem=True)
try:
for tag in tags:
if tag in self.blacklists['user_blacklist'].get(ctx.author.id, set()):
raise exc.TagBlacklisted(tag)
@ -973,9 +970,9 @@ class MsG:
@_remove_favorite.command(name='tags', aliases=['t'])
async def __remove_favorite_tags(self, ctx, *args):
try:
dest, tags = u.get_args(ctx, args, rem=True)
try:
for tag in tags:
try:
self.favorites[ctx.author.id].get('tags', set()).remove(tag)
@ -1174,9 +1171,9 @@ class MsG:
@_remove_tags.command(name='global', aliases=['gl', 'g'])
@commands.is_owner()
async def __remove_global_tags(self, ctx, *args):
try:
dest, tags = u.get_args(ctx, args, rem=True)
try:
for tag in tags:
try:
self.blacklists['global_blacklist'].remove(tag)
@ -1196,12 +1193,12 @@ class MsG:
@_remove_tags.command(name='channel', aliases=['ch', 'c'])
@commands.has_permissions(manage_channels=True)
async def __remove_channel_tags(self, ctx, *args):
try:
dest, tags = u.get_args(ctx, args, rem=True)
guild = ctx.guild if isinstance(
ctx.guild, d.Guild) else ctx.channel
try:
for tag in tags:
try:
self.blacklists['guild_blacklist'][guild.id][ctx.channel.id].remove(tag)
@ -1220,9 +1217,9 @@ class MsG:
@_remove_tags.command(name='me', aliases=['m'])
async def __remove_user_tags(self, ctx, *args):
try:
dest, tags = u.get_args(ctx, args, rem=True)
try:
for tag in tags:
try:
self.blacklists['user_blacklist'][ctx.author.id].remove(tag)

View file

@ -50,7 +50,7 @@ class Bot:
u.temp['restart_ch'] = ctx.channel.id
u.temp['restart_msg'] = ctx.message.id
u.dump(u.temp, 'temp/temp.pkl')
u.dump(u.temp, 'temp.pkl')
# loop = self.bot.loop.all_tasks()
# for task in loop:

View file

@ -54,8 +54,8 @@ async def on_ready():
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** ⚠ `{}`'.format(error))
await bot.get_channel(u.config['info_channel']).send('**ERROR** ⚠ `{}`'.format(error))
await bot.get_user(u.config['owner_id']).send('**ERROR** ⚠ `{}`'.format(error))
await bot.get_channel(u.config['info_channel']).send('**ERROR** ⚠ `{}`'.format(error))
# u.notify('E R R O R')
await bot.logout()
u.close(bot.loop)
@ -68,13 +68,15 @@ async def on_command_error(ctx, error):
await ctx.message.add_reaction('⛔️')
elif isinstance(error, errext.CommandNotFound):
print('INVALID COMMAND : {}'.format(error), file=sys.stderr)
await ctx.message.add_reaction('')
else:
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** ⚠ `{}`'.format(error))
await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** ⚠ `{}`'.format(error))
await bot.get_user(u.config['owner_id']).send('**COMMAND ERROR** ⚠ `{}`'.format(error))
await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** ⚠ `{}`'.format(error))
await exc.send_error(ctx, error)
await ctx.message.add_reaction('')
# u.notify('C O M M A N D E R R O R')

View file

@ -117,7 +117,7 @@ def get_args(ctx, args, *, rem=False, rm=False, lim=False):
destination = ctx
remaining = list(args[:])
remove = False
limit = 1
limit = lim
if '-d' in remaining or '-dm' in remaining:
destination = ctx.author
@ -142,9 +142,9 @@ def get_args(ctx, args, *, rem=False, rm=False, lim=False):
if lim:
for arg in remaining:
if len(arg) == 1:
if 1 <= len(arg) <= 2:
with suppress(ValueError):
if int(arg) <= 3 and int(arg) >= 1:
if 1 <= int(arg) <= lim:
limit = int(arg)
remaining.remove(arg)
break
@ -159,8 +159,8 @@ def get_args(ctx, args, *, rem=False, rm=False, lim=False):
if lim:
return destination, remaining, limit
return destination, remaining
return destination
if rm:
return destination, remove
if lim:
return destination, limit
return destination