mirror of
https://github.com/myned/modufur.git
synced 2024-12-23 22:27:27 +00:00
Merge branch 'dev'
This commit is contained in:
commit
0dbaccbd9b
6 changed files with 38 additions and 25 deletions
|
@ -22,7 +22,7 @@ class MsG:
|
|||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.LIMIT = 100
|
||||
self.RATE_LIMIT = 2.1
|
||||
self.RATE_LIMIT = u.RATE_LIMIT
|
||||
self.queue = asyncio.Queue()
|
||||
self.qualitifying = False
|
||||
|
||||
|
@ -550,6 +550,10 @@ class MsG:
|
|||
starred.append(values[c - 1]['url'])
|
||||
|
||||
await paginator.edit(content='**Image** `{}` **saved.**'.format(len(starred)))
|
||||
else:
|
||||
starred.remove(values[c - 1])['url']
|
||||
|
||||
await paginator.edit(content='**Image removed.**')
|
||||
|
||||
except exc.Right:
|
||||
if c < len(keys):
|
||||
|
@ -587,7 +591,7 @@ class MsG:
|
|||
for url in starred:
|
||||
await ctx.author.send(url)
|
||||
if len(starred) > 5:
|
||||
await asyncio.sleep(2.1)
|
||||
await asyncio.sleep(self.RATE_LIMIT)
|
||||
|
||||
# Messy code that checks image limit and tags in blacklists
|
||||
async def check_return_posts(self, *, ctx, booru='e621', tags=[], limit=1, previous={}):
|
||||
|
@ -728,6 +732,10 @@ class MsG:
|
|||
starred.append(values[c - 1]['url'])
|
||||
|
||||
await paginator.edit(content='**Image** `{}` **saved.**'.format(len(starred)))
|
||||
else:
|
||||
starred.remove(values[c - 1])['url']
|
||||
|
||||
await paginator.edit(content='**Image removed.**')
|
||||
|
||||
except exc.Right:
|
||||
if c % limit == 0:
|
||||
|
@ -783,7 +791,7 @@ class MsG:
|
|||
for url in starred:
|
||||
await ctx.author.send(url)
|
||||
if len(starred) > 5:
|
||||
await asyncio.sleep(2.1)
|
||||
await asyncio.sleep(self.RATE_LIMIT)
|
||||
|
||||
@e621_paginator.error
|
||||
async def e621_paginator_error(self, ctx, error):
|
||||
|
@ -1086,6 +1094,8 @@ class MsG:
|
|||
if alias_request:
|
||||
for dic in alias_request:
|
||||
self.aliases.setdefault(tag, set()).add(dic['name'])
|
||||
else:
|
||||
self.aliases.setdefault(tag, set())
|
||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||
u.dump(self.aliases, 'cogs/aliases.pkl')
|
||||
|
||||
|
@ -1107,6 +1117,8 @@ class MsG:
|
|||
if alias_request:
|
||||
for dic in alias_request:
|
||||
self.aliases.setdefault(tag, set()).add(dic['name'])
|
||||
else:
|
||||
self.aliases.setdefault(tag, set())
|
||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||
u.dump(self.aliases, 'cogs/aliases.pkl')
|
||||
|
||||
|
@ -1123,6 +1135,8 @@ class MsG:
|
|||
if alias_request:
|
||||
for dic in alias_request:
|
||||
self.aliases.setdefault(tag, set()).add(dic['name'])
|
||||
else:
|
||||
self.aliases.setdefault(tag, set())
|
||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||
u.dump(self.aliases, 'cogs/aliases.pkl')
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class Administration:
|
|||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.RATE_LIMIT = 2.1
|
||||
self.RATE_LIMIT = u.RATE_LIMIT
|
||||
self.queue = asyncio.Queue()
|
||||
self.deleting = False
|
||||
|
||||
|
@ -23,7 +23,7 @@ class Administration:
|
|||
for channel in u.tasks['auto_del']:
|
||||
temp = self.bot.get_channel(channel)
|
||||
self.bot.loop.create_task(self.queue_for_deletion(temp))
|
||||
print('AUTO-DELETING : #{}'.format(temp.name))
|
||||
print('AUTO-DELETING : #{}'.format(temp.id))
|
||||
self.bot.loop.create_task(self.delete())
|
||||
self.deleting = True
|
||||
|
||||
|
@ -131,7 +131,7 @@ class Administration:
|
|||
u.dump(u.tasks, 'cogs/tasks.pkl')
|
||||
if not u.tasks['auto_del']:
|
||||
self.deleting = False
|
||||
print('STOPPED : looping #{}'.format(channel.name))
|
||||
print('STOPPED : deleting #{}'.format(channel.id))
|
||||
await channel.send('**Stopped queueing messages for deletion in** {}**.**'.format(channel.mention), delete_after=5)
|
||||
|
||||
@commands.command(name='autodelete', aliases=['autodel', 'ad'])
|
||||
|
@ -146,7 +146,7 @@ class Administration:
|
|||
if not self.deleting:
|
||||
self.bot.loop.create_task(self.delete())
|
||||
self.deleting = True
|
||||
print('AUTO-DELETING : #{}'.format(ctx.channel.name))
|
||||
print('AUTO-DELETING : #{}'.format(ctx.channel.id))
|
||||
await ctx.send('**Auto-deleting all messages in {}.**'.format(ctx.channel.mention), delete_after=5)
|
||||
await ctx.message.add_reaction('✅')
|
||||
else:
|
||||
|
|
|
@ -29,8 +29,7 @@ class Bot:
|
|||
async def die(self, ctx):
|
||||
await ctx.message.add_reaction('🌙')
|
||||
|
||||
if isinstance(self.bot.get_channel(u.config['info_channel']), d.TextChannel):
|
||||
await self.bot.get_channel(u.config['info_channel']).send('**Shutting down** 🌙 . . .')
|
||||
await self.bot.get_channel(u.config['info_channel']).send('**Shutting down** 🌙 . . .')
|
||||
# loop = self.bot.loop.all_tasks()
|
||||
# for task in loop:
|
||||
# task.cancel()
|
||||
|
@ -46,14 +45,13 @@ class Bot:
|
|||
await ctx.message.add_reaction('💤')
|
||||
|
||||
print('\n| | | | | | | | | |\nR E S T A R T I N G\n| | | | | | | | | |\n')
|
||||
if isinstance(self.bot.get_channel(u.config['info_channel']), d.TextChannel):
|
||||
await self.bot.get_channel(u.config['info_channel']).send('**Restarting** 💤 . . .')
|
||||
await self.bot.get_channel(u.config['info_channel']).send('**Restarting** 💤 . . .')
|
||||
# u.notify('R E S T A R T I N G')
|
||||
|
||||
u.temp['restart_ch'] = ctx.channel.id
|
||||
u.temp['restart_msg'] = ctx.message.id
|
||||
u.dump(u.temp, 'temp/temp.pkl')
|
||||
|
||||
# u.notify('R E S T A R T I N G')
|
||||
# loop = self.bot.loop.all_tasks()
|
||||
# for task in loop:
|
||||
# task.cancel()
|
||||
|
@ -102,7 +100,7 @@ class Tools:
|
|||
|
||||
async def refresh(self, m, i='', o=''):
|
||||
global nl
|
||||
output = m.content[10:-3]
|
||||
output = m.content[10:-2]
|
||||
if len(nl.findall(output)) <= 20:
|
||||
await m.edit(content='```python\n{}\n{}\n>>>```'.format(output, self.format(i, o)))
|
||||
else:
|
||||
|
@ -136,8 +134,7 @@ class Tools:
|
|||
exe = await self.bot.wait_for('message', check=execute)
|
||||
except exc.Abort:
|
||||
raise exc.Abort
|
||||
finally:
|
||||
await exe.delete()
|
||||
await exe.delete()
|
||||
try:
|
||||
sys.stdout = io.StringIO()
|
||||
sys.stderr = io.StringIO()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
base = '⚠️ **An internal error has occurred.** Please notify my master! 🐺'
|
||||
base = '⚠️ **An internal error has occurred.** This has already been reported.'
|
||||
|
||||
|
||||
async def send_error(ctx, error):
|
||||
|
|
|
@ -40,9 +40,8 @@ async def on_ready():
|
|||
else:
|
||||
await bot.change_presence(game=None)
|
||||
|
||||
if isinstance(bot.get_channel(u.config['info_channel']), d.TextChannel):
|
||||
await bot.get_channel(u.config['info_channel']).send('**Started** ☀️ .')
|
||||
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** ☀️ .')
|
||||
# u.notify('C O N N E C T E D')
|
||||
if u.temp:
|
||||
channel = bot.get_channel(u.temp['restart_ch'])
|
||||
|
@ -53,13 +52,12 @@ async def on_ready():
|
|||
|
||||
@bot.event
|
||||
async def on_error(error, *args, **kwargs):
|
||||
if isinstance(bot.get_channel(u.config['info_channel']), d.TextChannel):
|
||||
await bot.get_channel(u.config['info_channel']).send('**ERROR** ⚠️ {}'.format(error))
|
||||
await bot.logout()
|
||||
u.close(bot.loop)
|
||||
print('\n! ! ! ! !\nE R R O R : {}\n! ! ! ! !\n'.format(error), file=sys.stderr)
|
||||
tb.print_exc()
|
||||
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)
|
||||
|
||||
|
||||
@bot.event
|
||||
|
@ -72,6 +70,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** ⚠️ {}'.format(error))
|
||||
await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** ⚠️ {}'.format(error))
|
||||
await exc.send_error(ctx, error)
|
||||
# u.notify('C O M M A N D E R R O R')
|
||||
|
||||
|
@ -101,8 +101,9 @@ async def reaction_remove(r, u):
|
|||
@checks.del_ctx()
|
||||
async def test(ctx):
|
||||
test = await ctx.send('Test')
|
||||
await test.add_reaction('✅')
|
||||
bot.add_listener(on_reaction_add)
|
||||
bot.add_listener(on_reaction_remove)
|
||||
raise Exception
|
||||
# await test.add_reaction('✅')
|
||||
# bot.add_listener(on_reaction_add)
|
||||
# bot.add_listener(on_reaction_remove)
|
||||
|
||||
bot.run(u.config['token'])
|
||||
|
|
|
@ -64,6 +64,7 @@ settings = setdefault('settings.pkl', {'del_ctx': []})
|
|||
tasks = setdefault('cogs/tasks.pkl', {'auto_del': [], 'auto_qual': [], 'auto_rev': []})
|
||||
temp = setdefault('temp/temp.pkl', {})
|
||||
|
||||
RATE_LIMIT = 2.2
|
||||
session = aiohttp.ClientSession()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue