Browse Source

added some comments and move logging to the end of the command to improve speed for end users.

tags/v2.0.0
Roxie Gibson 5 years ago
parent
commit
bd06239f1a
1 changed files with 7 additions and 4 deletions
  1. +7
    -4
      roxbot/cogs/reddit.py

+ 7
- 4
roxbot/cogs/reddit.py View File





class Scrapper: class Scrapper:
"""Scrapper is a class to aid in the scrapping of reddit subreddit's of images.
This includes its own caching system."""
# TODO: Reimplement eroshare, eroshae, and erome support. Also implement better api interaction with imgur now we require api key # TODO: Reimplement eroshare, eroshae, and erome support. Also implement better api interaction with imgur now we require api key
def __init__(self, cache_limit=10): def __init__(self, cache_limit=10):
self.post_cache = {} self.post_cache = {}
extensions = ("png", "jpg", "jpeg", "gif", "gifv", "mp4", "webm", "webp") extensions = ("png", "jpg", "jpeg", "gif", "gifv", "mp4", "webm", "webp")
for ext in extensions: for ext in extensions:
if fnmatch.fnmatch(url.split(".")[-1], ext+"*"): if fnmatch.fnmatch(url.split(".")[-1], ext+"*"):
# This is fixing issues where urls will have ".png?2" or some shit
return url return url


if await self._imgur_removed(url): if await self._imgur_removed(url):
else: else:
text = "" text = ""


# Not using a embed here because we can't use video in rich embeds but they work in embeds now :/
output = await ctx.send(title + text + url)
await roxbot.utils.delete_option(self.bot, ctx, output, self.bot.get_emoji(444410658101002261) or "❌")

if ctx.invoked_with == "subreddit" and isinstance(ctx.channel, discord.TextChannel): if ctx.invoked_with == "subreddit" and isinstance(ctx.channel, discord.TextChannel):
# Only log the command when it is this command being used. Not the inbuilt commands. # Only log the command when it is this command being used. Not the inbuilt commands.
logging = guild_settings.get(ctx.guild)["logging"] logging = guild_settings.get(ctx.guild)["logging"]
Time=roxbot.datetime_formatting.format(ctx.message.created_at) Time=roxbot.datetime_formatting.format(ctx.message.created_at)
) )


# Not using a embed here because we can't use video in rich embeds but they work in embeds now :/
output = await ctx.send(title + text + url)
await roxbot.utils.delete_option(self.bot, ctx, output, self.bot.get_emoji(444410658101002261) or "❌")

@commands.command() @commands.command()
async def aww(self, ctx): async def aww(self, ctx):
""" """

Loading…
Cancel
Save