Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63ec2142ac | ||
|
|
70e462e8f8 |
No files matched your search
+25
-15
@@ -14,12 +14,12 @@ class General(commands.Cog):
|
|||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.muzak_url = 'http://muzak.hoekveen.net:8001'
|
self.muzak_url = 'http://muzak.hoekveen.net:8001'
|
||||||
self.reddit = praw.Reddit(
|
self.r = praw.Reddit(
|
||||||
user_agent='StroopwafelBot',
|
user_agent='StroopwafelBot',
|
||||||
client_secret=os.getenv("STROOP_REDDIT_SECRET"),
|
client_secret=os.getenv("STROOP_REDDIT_SECRET"),
|
||||||
client_id=os.getenv("STROOP_REDDIT_ID")
|
client_id=os.getenv("STROOP_REDDIT_ID")
|
||||||
)
|
)
|
||||||
self.reddit.read_only = True
|
self.r.read_only = True
|
||||||
warnings.simplefilter("ignore")
|
warnings.simplefilter("ignore")
|
||||||
|
|
||||||
def get_emoji_embed(self, tag: str):
|
def get_emoji_embed(self, tag: str):
|
||||||
@@ -43,7 +43,7 @@ class General(commands.Cog):
|
|||||||
await ctx.channel.send(ctx.author.mention, embed=em)
|
await ctx.channel.send(ctx.author.mention, embed=em)
|
||||||
|
|
||||||
def get_aww_post(self):
|
def get_aww_post(self):
|
||||||
raww = self.reddit.subreddit('aww+catloaf+tuckedinkitties+babyelephantgifs+babybigcatgifs+blep+holdmynip+gingerkitty+cathighfive+catsstandingup+catsareassholes+eyebleach')
|
raww = self.r.subreddit('aww+catloaf+tuckedinkitties+babyelephantgifs+babybigcatgifs+blep+holdmynip+gingerkitty+cathighfive+catsstandingup+catsareassholes+eyebleach')
|
||||||
listing = list(raww.top(time_filter='month'))
|
listing = list(raww.top(time_filter='month'))
|
||||||
return random.choice(listing)
|
return random.choice(listing)
|
||||||
|
|
||||||
@@ -58,29 +58,39 @@ class General(commands.Cog):
|
|||||||
await ctx.channel.send(ctx.author.mention + ' ' + post.url)
|
await ctx.channel.send(ctx.author.mention + ' ' + post.url)
|
||||||
|
|
||||||
def get_kopieerpasta(self):
|
def get_kopieerpasta(self):
|
||||||
rkopieerpasta = self.reddit.subreddit('kopieerpasta')
|
rkopieerpasta = self.r.subreddit('kopieerpasta')
|
||||||
try:
|
try:
|
||||||
post = random.choice(list(rkopieerpasta.top(time_filter='year', limit=100)))
|
post = rkopieerpasta.random()
|
||||||
if post != None:
|
|
||||||
|
# Subreddits kunnen de random functie uitzetten, dus dit is de fallback:
|
||||||
|
if post == None:
|
||||||
|
listing = list(rkopieerpasta.top(time_filter='month', limit=250))
|
||||||
|
post = random.choice(listing)
|
||||||
|
|
||||||
return post
|
return post
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@commands.command()
|
@commands.command(pass_context=True)
|
||||||
async def kopieerpasta(self, ctx):
|
async def kopieerpasta(self, ctx):
|
||||||
"""Een willekeurige kopieerpasta"""
|
"""Een willekeurige shitpost"""
|
||||||
post = None
|
|
||||||
for _ in range(10):
|
|
||||||
post = self.get_kopieerpasta()
|
post = self.get_kopieerpasta()
|
||||||
if post and post.selftext and post.title and len(post.selftext + post.title) < 1990:
|
if not post:
|
||||||
break
|
await ctx.channel.send("Geen kopieerpasta voor jou vandaag.")
|
||||||
|
return
|
||||||
|
print(post.url)
|
||||||
|
ATTEMPTS = 10
|
||||||
|
a = 0
|
||||||
|
while len(post.selftext + post.title) >= 1990 and a < ATTEMPTS:
|
||||||
|
post = self.get_kopieerpasta()
|
||||||
|
print(post.url)
|
||||||
|
a += 1
|
||||||
try:
|
try:
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
pass #boeie
|
print("No permission to delete message")
|
||||||
|
|
||||||
if post:
|
if len(post.selftext + post.title) < 1990:
|
||||||
await ctx.channel.send('**'+post.title+'**```'+post.selftext+'```')
|
await ctx.channel.send('**'+post.title+'**```'+post.selftext+'```')
|
||||||
else:
|
else:
|
||||||
await ctx.channel.send("Geen kopieerpasta voor jou vandaag.")
|
await ctx.channel.send("Geen kopieerpasta voor jou vandaag.")
|
||||||
|
|||||||
+23
@@ -853,3 +853,26 @@ class Shitpost(commands.Cog):
|
|||||||
"""Is zaagmans al langsgeweest? Is de week al doormidden. Wie weet."""
|
"""Is zaagmans al langsgeweest? Is de week al doormidden. Wie weet."""
|
||||||
message = ctx.author.mention + ": " + self.get_zaagmans()
|
message = ctx.author.mention + ": " + self.get_zaagmans()
|
||||||
await ctx.channel.send(message)
|
await ctx.channel.send(message)
|
||||||
|
|
||||||
|
# checkt of de relevante xkcd bestaat
|
||||||
|
def xkcd_exists(self, url):
|
||||||
|
try:
|
||||||
|
response = requests.get(url, timeout=10)
|
||||||
|
return response.content.startswith(b"\x89PNG") > 0 #T/F
|
||||||
|
except requests.RequestException:
|
||||||
|
return False
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def relevantxkcd(self, ctx, *, query: str):
|
||||||
|
"""There is always a relevant XKCD
|
||||||
|
Bijvoorbeeld:
|
||||||
|
!relevantxkcd bobby tables
|
||||||
|
"""
|
||||||
|
pic_url = "https://relevant-xkcd.com/@" + query.replace(" ", "_")
|
||||||
|
em = discord.Embed(description="Altijd weer relevant.")
|
||||||
|
em.set_image(url=pic_url)
|
||||||
|
|
||||||
|
if self.xkcd_exists(pic_url):
|
||||||
|
await ctx.channel.send(ctx.author.mention + ' een XKCD over "' + query + '":\n', embed=em)
|
||||||
|
else:
|
||||||
|
await ctx.channel.send(f'Ik kan helaas geen XKCD vinden met als onderwerp "{query}".')
|
||||||
Reference in new issue
Block a user