1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-12-25 06:37:29 +00:00

Merge branch 'dev'

This commit is contained in:
Myned 2017-12-31 23:13:05 -05:00
commit b88dc0ea25

View file

@ -147,13 +147,16 @@ class MsG:
async def queue_for_hearts(self, *, message=None, send=None, channel=None, reaction=True, timeout=60 * 60): async def queue_for_hearts(self, *, message=None, send=None, channel=None, reaction=True, timeout=60 * 60):
def on_reaction(reaction, user): def on_reaction(reaction, user):
if reaction.emoji == '\N{HEAVY BLACK HEART}' and reaction.message.id == message.id: if reaction.emoji == '\N{HEAVY BLACK HEART}' and reaction.message.id == message.id and not user.bot:
raise exc.Save(user) raise exc.Save(user)
return False return False
def on_message(msg): def on_reaction_channel(reaction, user):
if 'stop h' in msg.content.lower(): if reaction.message.channel.id == channel.id and not user.bot:
raise exc.Abort if reaction.emoji == '\N{OCTAGONAL SIGN}' and user.permissions_in(reaction.message.channel).administrator:
return msg.channel.id == channel.id and (re.search('(https?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', msg.content) or msg.attachments) raise exc.Abort
if reaction.emoji == '\N{HEAVY BLACK HEART}' and (re.search('(https?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', reaction.message.content) or reaction.message.attachments):
raise exc.Save(user, reaction.message)
return False
if message: if message:
try: try:
@ -172,13 +175,12 @@ class MsG:
await message.add_reaction('\N{WHITE HEAVY CHECK MARK}') await message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
else: else:
try: try:
async for message in channel.history(limit=300):
if re.search('(https?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) or message.attachments:
self.bot.loop.create_task(self._wait_for_reaction(message))
while self.hearting: while self.hearting:
message = await self.bot.wait_for('message', check=on_message) try:
self.bot.loop.create_task(self._wait_for_reaction(message)) await self.bot.wait_for('reaction_add', check=on_reaction_channel)
except exc.Save as e:
await self.heartqueue.put((e.user, message))
except exc.Abort: except exc.Abort:
u.tasks['auto_hrt'].remove(channel.id) u.tasks['auto_hrt'].remove(channel.id)
@ -186,19 +188,6 @@ class MsG:
print('STOPPED : auto-hearting in #{}'.format(channel.name)) print('STOPPED : auto-hearting in #{}'.format(channel.name))
await channel.send('**Stopped queueing messages for hearting in** {}'.format(channel.mention), delete_after=5) await channel.send('**Stopped queueing messages for hearting in** {}'.format(channel.mention), delete_after=5)
async def _wait_for_reaction(self, message):
def on_reaction(reaction, user):
if reaction.emoji == '\N{HEAVY BLACK HEART}' and reaction.message.id == message.id:
raise exc.Save(user)
return False
while self.hearting:
try:
await self.bot.wait_for('reaction_add', check=on_reaction)
except exc.Save as e:
await self.heartqueue.put((e.user, message))
@cmds.command(name='autoheart', aliases=['autohrt']) @cmds.command(name='autoheart', aliases=['autohrt'])
@cmds.has_permissions(administrator=True) @cmds.has_permissions(administrator=True)
async def auto_heart(self, ctx): async def auto_heart(self, ctx):
@ -213,8 +202,8 @@ class MsG:
raise exc.Exists raise exc.Exists
except exc.Exists: except exc.Exists:
await ctx.send('**Already auto-hearting in {}.** Type `stop h(earting)` to stop.'.format(ctx.channel.mention), delete_after=7) message = await ctx.send('**Already auto-hearting in {}.** React with \N{OCTAGONAL SIGN} to stop.'.format(ctx.channel.mention))
await ctx.message.add_reaction('\N{CROSS MARK}') await message.add_reaction('\N{OCTAGONAL SIGN}')
# @cmds.command() # @cmds.command()
# async def auto_post(self, ctx): # async def auto_post(self, ctx):