Selaa lähdekoodia

.

tags/v1.0.0
roxie 6 vuotta sitten
vanhempi
commit
3a38e0d69c
1 muutettua tiedostoa jossa 70 lisäystä ja 6 poistoa
  1. +70
    -6
      cogs/reddit.py

+ 70
- 6
cogs/reddit.py Näytä tiedosto

self.servers = self.con.servers self.servers = self.con.servers


@bot.command(pass_context=True) @bot.command(pass_context=True)
async def reddit(self, ctx, subreddit):
async def subreddit(self, ctx, subreddit):
"""
Grabs an image (png, gif, gifv, webm) from the subreddit inputted.
Exmaple:
{command_prefix}subreddit pics
"""
links = Scrapper().linkget(subreddit, True) links = Scrapper().linkget(subreddit, True)
title = ""
if not links: if not links:
return await self.bot.say("Error ;-; That subreddit probably doesn't exist. Please check your spelling") return await self.bot.say("Error ;-; That subreddit probably doesn't exist. Please check your spelling")
url = "" url = ""
for x in range(10): for x in range(10):
choice = random.choice(links) choice = random.choice(links)
title = "**{}** from /r/{}\n".format(choice["data"]["title"], subreddit)
if choice["data"]["over_18"] and not self.servers[ctx.message.server.id]["nsfw"]["enabled"]: if choice["data"]["over_18"] and not self.servers[ctx.message.server.id]["nsfw"]["enabled"]:
return await self.bot.say("This server doesn't have my NSFW stuff enabled. This extends to posting NFSW content from Reddit.") return await self.bot.say("This server doesn't have my NSFW stuff enabled. This extends to posting NFSW content from Reddit.")
url = Scrapper().retriveurl(choice["data"]["url"]) url = Scrapper().retriveurl(choice["data"]["url"])
else: else:
text = "" text = ""


return await self.bot.say(text + url)
return await self.bot.say(title + text + url)




@bot.command()
async def aww(self):
links = Scrapper().linkget("aww", True)
@bot.command(pass_context=True)
async def aww(self, ctx):
"""
Gives you cute pics from reddit
"""
subreddit = "aww"
links = Scrapper().linkget(subreddit, True)
if not links:
return await self.bot.say("Error ;-; That subreddit probably doesn't exist. Please check your spelling")

choice = random.choice(links)
title = "**{}** from /r/{}\n".format(choice["data"]["title"], subreddit)
if choice["data"]["over_18"] and not self.servers[ctx.message.server.id]["nsfw"]["enabled"]:
return await self.bot.say(
"This server doesn't have my NSFW stuff enabled. This extends to posting NFSW content from Reddit.")
url = Scrapper().retriveurl(choice["data"]["url"])

if url.split("/")[-2] == "a":
text = "This is an album, click on the link to see more. "
else:
text = ""
return await self.bot.say(title + text + url)

@bot.command(pass_context=True)
async def feedme(self, ctx):
"""
Feeds you with food porn. Uses multiple subreddits
Yes, I was very hungry when trying to find the subreddits for this command.
"""
subreddits = ["foodporn", "food", "DessertPorn", "tonightsdinner", "eatsandwiches", "steak", "burgers", "Pizza", "grilledcheese", "PutAnEggOnIt", "sushi"]
subreddit = random.choice(subreddits)
links = Scrapper().linkget(subreddit, True)
if not links:
return await self.bot.say("Error ;-; That subreddit probably doesn't exist. Please check your spelling")

choice = random.choice(links)
title = "**{}** from /r/{}\n".format(choice["data"]["title"], subreddit)
if choice["data"]["over_18"] and not self.servers[ctx.message.server.id]["nsfw"]["enabled"]:
return await self.bot.say(
"This server doesn't have my NSFW stuff enabled. This extends to posting NFSW content from Reddit.")
url = Scrapper().retriveurl(choice["data"]["url"])

if url.split("/")[-2] == "a":
text = "This is an album, click on the link to see more. "
else:
text = ""
return await self.bot.say(title + text + url)


@bot.command(pass_context=True)
async def traa(self, ctx):
"""
Gives you the best trans memes ever
"""
subreddit = "traaaaaaannnnnnnnnns"
links = Scrapper().linkget(subreddit, True)
if not links: if not links:
return await self.bot.say("Error ;-; That subreddit probably doesn't exist. Please check your spelling") return await self.bot.say("Error ;-; That subreddit probably doesn't exist. Please check your spelling")


choice = random.choice(links) choice = random.choice(links)
title = "**{}** from /r/{}\n".format(choice["data"]["title"], subreddit)
if choice["data"]["over_18"] and not self.servers[ctx.message.server.id]["nsfw"]["enabled"]:
return await self.bot.say(
"This server doesn't have my NSFW stuff enabled. This extends to posting NFSW content from Reddit.")
url = Scrapper().retriveurl(choice["data"]["url"]) url = Scrapper().retriveurl(choice["data"]["url"])


if url.split("/")[-2] == "a": if url.split("/")[-2] == "a":
text = "This is an album, click on the link to see more. " text = "This is an album, click on the link to see more. "
else: else:
text = "" text = ""
return await self.bot.say(text + url)
return await self.bot.say(title + text + url)




def setup(Bot): def setup(Bot):

Loading…
Peruuta
Tallenna