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:
parent
f4da3c6705
commit
6f38e0bc8e
11 changed files with 1792 additions and 1793 deletions
|
@ -24,6 +24,7 @@ class MsG:
|
||||||
self.color = d.Color(0x1A1A1A)
|
self.color = d.Color(0x1A1A1A)
|
||||||
self.LIMIT = 100
|
self.LIMIT = 100
|
||||||
self.RATE_LIMIT = u.RATE_LIMIT
|
self.RATE_LIMIT = u.RATE_LIMIT
|
||||||
|
self.HISTORY_LIMIT = 99
|
||||||
self.queue = asyncio.Queue()
|
self.queue = asyncio.Queue()
|
||||||
self.qualitifying = False
|
self.qualitifying = False
|
||||||
|
|
||||||
|
@ -83,9 +84,9 @@ class MsG:
|
||||||
@commands.command(name='getimage', aliases=['geti', 'gi'])
|
@commands.command(name='getimage', aliases=['geti', 'gi'])
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def get_image(self, ctx, *args):
|
async def get_image(self, ctx, *args):
|
||||||
|
try:
|
||||||
dest, urls = u.get_args(ctx, args, rem=True)
|
dest, urls = u.get_args(ctx, args, rem=True)
|
||||||
|
|
||||||
try:
|
|
||||||
if not urls:
|
if not urls:
|
||||||
raise exc.MissingArgument
|
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')
|
@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()
|
@checks.del_ctx()
|
||||||
async def reverse_image_search(self, ctx, *args):
|
async def reverse_image_search(self, ctx, *args):
|
||||||
|
try:
|
||||||
dest, urls = u.get_args(ctx, args, rem=True)
|
dest, urls = u.get_args(ctx, args, rem=True)
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
try:
|
|
||||||
if not urls and not ctx.message.attachments:
|
if not urls and not ctx.message.attachments:
|
||||||
raise exc.MissingArgument
|
raise exc.MissingArgument
|
||||||
|
|
||||||
|
@ -151,10 +152,10 @@ class MsG:
|
||||||
@commands.command(name='quality', aliases=['qual', 'qrev', 'qis'])
|
@commands.command(name='quality', aliases=['qual', 'qrev', 'qis'])
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def quality_reverse_image_search(self, ctx, *args):
|
async def quality_reverse_image_search(self, ctx, *args):
|
||||||
|
try:
|
||||||
dest, urls = u.get_args(ctx, args, rem=True)
|
dest, urls = u.get_args(ctx, args, rem=True)
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
try:
|
|
||||||
if not urls and not ctx.message.attachments:
|
if not urls and not ctx.message.attachments:
|
||||||
raise exc.MissingArgument
|
raise exc.MissingArgument
|
||||||
|
|
||||||
|
@ -198,16 +199,14 @@ class MsG:
|
||||||
@commands.command(name='reversify', aliases=['revify', 'risify', 'rify'])
|
@commands.command(name='reversify', aliases=['revify', 'risify', 'rify'])
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def reversify(self, ctx, *args):
|
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 = []
|
urls = []
|
||||||
attachments = []
|
attachments = []
|
||||||
|
|
||||||
if not ctx.author.permissions_in(ctx.channel).manage_messages:
|
if not ctx.author.permissions_in(ctx.channel).manage_messages:
|
||||||
dest = ctx.author
|
dest = ctx.author
|
||||||
|
|
||||||
try:
|
|
||||||
limit = int(limit)
|
|
||||||
|
|
||||||
async for message in ctx.channel.history(limit=limit + 1):
|
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:
|
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)
|
urls.append(message)
|
||||||
|
@ -267,16 +266,14 @@ class MsG:
|
||||||
@commands.command(name='qualitify', aliases=['qualify', 'qrevify', 'qrisify', 'qify'])
|
@commands.command(name='qualitify', aliases=['qualify', 'qrevify', 'qrisify', 'qify'])
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def qualitify(self, ctx, *args):
|
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 = []
|
urls = []
|
||||||
attachments = []
|
attachments = []
|
||||||
|
|
||||||
if not ctx.author.permissions_in(ctx.channel).manage_messages:
|
if not ctx.author.permissions_in(ctx.channel).manage_messages:
|
||||||
dest = ctx.author
|
dest = ctx.author
|
||||||
|
|
||||||
try:
|
|
||||||
limit = int(limit)
|
|
||||||
|
|
||||||
async for message in ctx.channel.history(limit=limit + 1):
|
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:
|
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)
|
urls.append(message)
|
||||||
|
@ -498,11 +495,11 @@ class MsG:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
dest, query = u.get_args(ctx, args, rem=True)
|
dest, query = u.get_args(ctx, args, rem=True)
|
||||||
starred = []
|
starred = []
|
||||||
c = 1
|
c = 1
|
||||||
|
|
||||||
try:
|
|
||||||
await dest.trigger_typing()
|
await dest.trigger_typing()
|
||||||
|
|
||||||
pool, posts = await self.return_pool(ctx, booru='e621', query=query)
|
pool, posts = await self.return_pool(ctx, booru='e621', query=query)
|
||||||
|
@ -678,12 +675,12 @@ class MsG:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
dest, tags = u.get_args(ctx, args, rem=True)
|
||||||
limit = self.LIMIT / 5
|
limit = self.LIMIT / 5
|
||||||
starred = []
|
starred = []
|
||||||
c = 1
|
c = 1
|
||||||
|
|
||||||
try:
|
|
||||||
tags = self.get_favorites(ctx, tags)
|
tags = self.get_favorites(ctx, tags)
|
||||||
|
|
||||||
await ctx.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
@ -816,9 +813,9 @@ class MsG:
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
@checks.is_nsfw()
|
@checks.is_nsfw()
|
||||||
async def e621(self, ctx, *args):
|
async def e621(self, ctx, *args):
|
||||||
dest, args, limit = u.get_args(ctx, args, rem=True, lim=True)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
dest, args, limit = u.get_args(ctx, args, rem=True, lim=3)
|
||||||
|
|
||||||
tags = self.get_favorites(ctx, args)
|
tags = self.get_favorites(ctx, args)
|
||||||
|
|
||||||
await dest.trigger_typing()
|
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])')
|
@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()
|
@checks.del_ctx()
|
||||||
async def e926(self, ctx, *args):
|
async def e926(self, ctx, *args):
|
||||||
dest, args, limit = u.get_args(ctx, args, rem=True, lim=True)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
dest, args, limit = u.get_args(ctx, args, rem=True, lim=3)
|
||||||
|
|
||||||
tags = self.get_favorites(ctx, args)
|
tags = self.get_favorites(ctx, args)
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await dest.trigger_typing()
|
||||||
|
@ -941,9 +938,9 @@ class MsG:
|
||||||
|
|
||||||
@_add_favorite.command(name='tags', aliases=['t'])
|
@_add_favorite.command(name='tags', aliases=['t'])
|
||||||
async def __add_favorite_tags(self, ctx, *args):
|
async def __add_favorite_tags(self, ctx, *args):
|
||||||
|
try:
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
dest, tags = u.get_args(ctx, args, rem=True)
|
||||||
|
|
||||||
try:
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
if tag in self.blacklists['user_blacklist'].get(ctx.author.id, set()):
|
if tag in self.blacklists['user_blacklist'].get(ctx.author.id, set()):
|
||||||
raise exc.TagBlacklisted(tag)
|
raise exc.TagBlacklisted(tag)
|
||||||
|
@ -973,9 +970,9 @@ class MsG:
|
||||||
|
|
||||||
@_remove_favorite.command(name='tags', aliases=['t'])
|
@_remove_favorite.command(name='tags', aliases=['t'])
|
||||||
async def __remove_favorite_tags(self, ctx, *args):
|
async def __remove_favorite_tags(self, ctx, *args):
|
||||||
|
try:
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
dest, tags = u.get_args(ctx, args, rem=True)
|
||||||
|
|
||||||
try:
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
try:
|
try:
|
||||||
self.favorites[ctx.author.id].get('tags', set()).remove(tag)
|
self.favorites[ctx.author.id].get('tags', set()).remove(tag)
|
||||||
|
@ -1174,9 +1171,9 @@ class MsG:
|
||||||
@_remove_tags.command(name='global', aliases=['gl', 'g'])
|
@_remove_tags.command(name='global', aliases=['gl', 'g'])
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def __remove_global_tags(self, ctx, *args):
|
async def __remove_global_tags(self, ctx, *args):
|
||||||
|
try:
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
dest, tags = u.get_args(ctx, args, rem=True)
|
||||||
|
|
||||||
try:
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
try:
|
try:
|
||||||
self.blacklists['global_blacklist'].remove(tag)
|
self.blacklists['global_blacklist'].remove(tag)
|
||||||
|
@ -1196,12 +1193,12 @@ class MsG:
|
||||||
@_remove_tags.command(name='channel', aliases=['ch', 'c'])
|
@_remove_tags.command(name='channel', aliases=['ch', 'c'])
|
||||||
@commands.has_permissions(manage_channels=True)
|
@commands.has_permissions(manage_channels=True)
|
||||||
async def __remove_channel_tags(self, ctx, *args):
|
async def __remove_channel_tags(self, ctx, *args):
|
||||||
|
try:
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
dest, tags = u.get_args(ctx, args, rem=True)
|
||||||
|
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
|
||||||
try:
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
try:
|
try:
|
||||||
self.blacklists['guild_blacklist'][guild.id][ctx.channel.id].remove(tag)
|
self.blacklists['guild_blacklist'][guild.id][ctx.channel.id].remove(tag)
|
||||||
|
@ -1220,9 +1217,9 @@ class MsG:
|
||||||
|
|
||||||
@_remove_tags.command(name='me', aliases=['m'])
|
@_remove_tags.command(name='me', aliases=['m'])
|
||||||
async def __remove_user_tags(self, ctx, *args):
|
async def __remove_user_tags(self, ctx, *args):
|
||||||
|
try:
|
||||||
dest, tags = u.get_args(ctx, args, rem=True)
|
dest, tags = u.get_args(ctx, args, rem=True)
|
||||||
|
|
||||||
try:
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
try:
|
try:
|
||||||
self.blacklists['user_blacklist'][ctx.author.id].remove(tag)
|
self.blacklists['user_blacklist'][ctx.author.id].remove(tag)
|
||||||
|
|
|
@ -50,7 +50,7 @@ class Bot:
|
||||||
|
|
||||||
u.temp['restart_ch'] = ctx.channel.id
|
u.temp['restart_ch'] = ctx.channel.id
|
||||||
u.temp['restart_msg'] = ctx.message.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()
|
# loop = self.bot.loop.all_tasks()
|
||||||
# for task in loop:
|
# for task in loop:
|
||||||
|
|
|
@ -54,8 +54,8 @@ async def on_ready():
|
||||||
async def on_error(error, *args, **kwargs):
|
async def on_error(error, *args, **kwargs):
|
||||||
print('\n! ! ! ! !\nE R R O R : {}\n! ! ! ! !\n'.format(error), file=sys.stderr)
|
print('\n! ! ! ! !\nE R R O R : {}\n! ! ! ! !\n'.format(error), file=sys.stderr)
|
||||||
tb.print_exc()
|
tb.print_exc()
|
||||||
await bot.get_user(u.config['owner_id']).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))
|
await bot.get_channel(u.config['info_channel']).send('**ERROR** ⚠ `{}`'.format(error))
|
||||||
# u.notify('E R R O R')
|
# u.notify('E R R O R')
|
||||||
await bot.logout()
|
await bot.logout()
|
||||||
u.close(bot.loop)
|
u.close(bot.loop)
|
||||||
|
@ -68,13 +68,15 @@ async def on_command_error(ctx, error):
|
||||||
await ctx.message.add_reaction('⛔️')
|
await ctx.message.add_reaction('⛔️')
|
||||||
elif isinstance(error, errext.CommandNotFound):
|
elif isinstance(error, errext.CommandNotFound):
|
||||||
print('INVALID COMMAND : {}'.format(error), file=sys.stderr)
|
print('INVALID COMMAND : {}'.format(error), file=sys.stderr)
|
||||||
|
await ctx.message.add_reaction('❌')
|
||||||
else:
|
else:
|
||||||
print('\n! ! ! ! ! ! ! ! ! ! ! !\nC O M M A N D E R R O R : {}\n! ! ! ! ! ! ! ! ! ! ! !\n'.format(
|
print('\n! ! ! ! ! ! ! ! ! ! ! !\nC O M M A N D E R R O R : {}\n! ! ! ! ! ! ! ! ! ! ! !\n'.format(
|
||||||
error), file=sys.stderr)
|
error), file=sys.stderr)
|
||||||
tb.print_exception(type(error), error, error.__traceback__, 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_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_channel(u.config['info_channel']).send('**COMMAND ERROR** ⚠ `{}`'.format(error))
|
||||||
await exc.send_error(ctx, 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')
|
# u.notify('C O M M A N D E R R O R')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ def get_args(ctx, args, *, rem=False, rm=False, lim=False):
|
||||||
destination = ctx
|
destination = ctx
|
||||||
remaining = list(args[:])
|
remaining = list(args[:])
|
||||||
remove = False
|
remove = False
|
||||||
limit = 1
|
limit = lim
|
||||||
|
|
||||||
if '-d' in remaining or '-dm' in remaining:
|
if '-d' in remaining or '-dm' in remaining:
|
||||||
destination = ctx.author
|
destination = ctx.author
|
||||||
|
@ -142,9 +142,9 @@ def get_args(ctx, args, *, rem=False, rm=False, lim=False):
|
||||||
|
|
||||||
if lim:
|
if lim:
|
||||||
for arg in remaining:
|
for arg in remaining:
|
||||||
if len(arg) == 1:
|
if 1 <= len(arg) <= 2:
|
||||||
with suppress(ValueError):
|
with suppress(ValueError):
|
||||||
if int(arg) <= 3 and int(arg) >= 1:
|
if 1 <= int(arg) <= lim:
|
||||||
limit = int(arg)
|
limit = int(arg)
|
||||||
remaining.remove(arg)
|
remaining.remove(arg)
|
||||||
break
|
break
|
||||||
|
@ -159,8 +159,8 @@ def get_args(ctx, args, *, rem=False, rm=False, lim=False):
|
||||||
if lim:
|
if lim:
|
||||||
return destination, remaining, limit
|
return destination, remaining, limit
|
||||||
return destination, remaining
|
return destination, remaining
|
||||||
return destination
|
|
||||||
if rm:
|
if rm:
|
||||||
return destination, remove
|
return destination, remove
|
||||||
if lim:
|
if lim:
|
||||||
return destination, limit
|
return destination, limit
|
||||||
|
return destination
|
||||||
|
|
Loading…
Reference in a new issue