mirror of
https://github.com/myned/modufur.git
synced 2024-11-02 05:02:39 +00:00
Merge branch 'dev'
This commit is contained in:
commit
0140a7711f
1 changed files with 41 additions and 37 deletions
|
@ -280,7 +280,7 @@ class MsG:
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args, limit=self.HISTORY_LIMIT / 5)
|
kwargs = u.get_kwargs(ctx, args, limit=self.HISTORY_LIMIT / 5)
|
||||||
dest, remove, limit = kwargs['destination'], kwargs['remove'], kwargs['limit']
|
dest, remove, limit = kwargs['destination'], kwargs['remove'], kwargs['limit']
|
||||||
urls = []
|
links = {}
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
if not ctx.author.permissions_in(ctx.channel).manage_messages:
|
if not ctx.author.permissions_in(ctx.channel).manage_messages:
|
||||||
|
@ -290,25 +290,27 @@ class MsG:
|
||||||
if c >= limit:
|
if c >= limit:
|
||||||
break
|
break
|
||||||
if message.author.id != self.bot.user.id and (re.search('(https?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) is not None or message.embeds or message.attachments):
|
if message.author.id != self.bot.user.id and (re.search('(https?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) is not None or message.embeds or message.attachments):
|
||||||
|
links[message] = []
|
||||||
for match in re.finditer('(https?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content):
|
for match in re.finditer('(https?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content):
|
||||||
urls.append(match.group(0))
|
links[message].append(match.group(0))
|
||||||
for embed in message.embeds:
|
for embed in message.embeds:
|
||||||
if embed.image.url is not d.Embed.Empty:
|
if embed.image.url is not d.Embed.Empty:
|
||||||
urls.append(embed.image.url)
|
links[message].append(embed.image.url)
|
||||||
for attachment in message.attachments:
|
for attachment in message.attachments:
|
||||||
urls.append(attachment.url)
|
links[message].append(attachment.url)
|
||||||
|
|
||||||
await message.add_reaction('⏳')
|
await message.add_reaction('⏳')
|
||||||
c += 1
|
c += 1
|
||||||
|
|
||||||
if not urls:
|
if not links:
|
||||||
raise exc.NotFound
|
raise exc.NotFound
|
||||||
|
|
||||||
|
for message, urls in links.items():
|
||||||
for url in urls:
|
for url in urls:
|
||||||
try:
|
try:
|
||||||
await dest.trigger_typing()
|
await dest.trigger_typing()
|
||||||
|
|
||||||
await dest.send('**Probable match from** {} `{} / {}`\n{}'.format(message.author.display_name, urls.index(url) + 1, len(urls), await scraper.get_post(url)))
|
await dest.send('`{} / {}` **Probable match from** {}\n{}'.format(urls.index(url) + 1, len(urls), message.author.display_name, await scraper.get_post(url)))
|
||||||
await message.add_reaction('✅')
|
await message.add_reaction('✅')
|
||||||
|
|
||||||
await asyncio.sleep(self.RATE_LIMIT)
|
await asyncio.sleep(self.RATE_LIMIT)
|
||||||
|
@ -340,7 +342,7 @@ class MsG:
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args, limit=self.HISTORY_LIMIT / 5)
|
kwargs = u.get_kwargs(ctx, args, limit=self.HISTORY_LIMIT / 5)
|
||||||
dest, remove, limit = kwargs['destination'], kwargs['remove'], kwargs['limit']
|
dest, remove, limit = kwargs['destination'], kwargs['remove'], kwargs['limit']
|
||||||
urls = []
|
links = {}
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
if not ctx.author.permissions_in(ctx.channel).manage_messages:
|
if not ctx.author.permissions_in(ctx.channel).manage_messages:
|
||||||
|
@ -350,27 +352,29 @@ class MsG:
|
||||||
if c >= limit:
|
if c >= limit:
|
||||||
break
|
break
|
||||||
if message.author.id != self.bot.user.id and (re.search('(https?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) is not None or message.embeds or message.attachments):
|
if message.author.id != self.bot.user.id and (re.search('(https?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content) is not None or message.embeds or message.attachments):
|
||||||
|
links[message] = []
|
||||||
for match in re.finditer('(https?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content):
|
for match in re.finditer('(https?:\/\/[^ ]*\.(?:gif|png|jpg|jpeg))', message.content):
|
||||||
urls.append(match.group(0))
|
links[message].append(match.group(0))
|
||||||
for embed in message.embeds:
|
for embed in message.embeds:
|
||||||
if embed.image.url is not d.Embed.Empty:
|
if embed.image.url is not d.Embed.Empty:
|
||||||
urls.append(embed.image.url)
|
links[message].append(embed.image.url)
|
||||||
for attachment in message.attachments:
|
for attachment in message.attachments:
|
||||||
urls.append(attachment.url)
|
links[message].append(attachment.url)
|
||||||
|
|
||||||
await message.add_reaction('⏳')
|
await message.add_reaction('⏳')
|
||||||
c += 1
|
c += 1
|
||||||
|
|
||||||
if not urls:
|
if not links:
|
||||||
raise exc.NotFound
|
raise exc.NotFound
|
||||||
|
|
||||||
|
for message, urls in links.items():
|
||||||
for url in urls:
|
for url in urls:
|
||||||
try:
|
try:
|
||||||
await dest.trigger_typing()
|
await dest.trigger_typing()
|
||||||
|
|
||||||
post = await scraper.get_post(url)
|
post = await scraper.get_post(url)
|
||||||
|
|
||||||
await dest.send('**Probable match from** {} `{} / {}`\n{}'.format(message.author.display_name, urls.index(url) + 1, len(urls), await scraper.get_image(post)))
|
await dest.send('`{} / {}` **Probable match from** {}\n{}'.format(urls.index(url) + 1, len(urls), message.author.display_name, await scraper.get_image(post)))
|
||||||
await message.add_reaction('✅')
|
await message.add_reaction('✅')
|
||||||
|
|
||||||
await asyncio.sleep(self.RATE_LIMIT)
|
await asyncio.sleep(self.RATE_LIMIT)
|
||||||
|
|
Loading…
Reference in a new issue