Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
566704387d | ||
|
|
6fe6a756bb | ||
|
|
7be76c00c3 | ||
|
|
67a82abaca | ||
|
|
9d4ffc8eff | ||
|
|
63ec2142ac | ||
|
|
f0897467d0 | ||
|
|
70e462e8f8 | ||
|
|
e184267eca | ||
|
|
53fde8c8c5 | ||
|
|
16cf8c673b | ||
|
|
2ebde2e4db |
No files matched your search
+853
-767
File diff suppressed because it is too large.
Load diff
+16
-26
@@ -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.r = praw.Reddit(
|
self.reddit = 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.r.read_only = True
|
self.reddit.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.r.subreddit('aww+catloaf+tuckedinkitties+babyelephantgifs+babybigcatgifs+blep+holdmynip+gingerkitty+cathighfive+catsstandingup+catsareassholes+eyebleach')
|
raww = self.reddit.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,39 +58,29 @@ 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.r.subreddit('kopieerpasta')
|
rkopieerpasta = self.reddit.subreddit('kopieerpasta')
|
||||||
try:
|
try:
|
||||||
post = rkopieerpasta.random()
|
post = random.choice(list(rkopieerpasta.top(time_filter='year', limit=100)))
|
||||||
|
if post != None:
|
||||||
# Subreddits kunnen de random functie uitzetten, dus dit is de fallback:
|
return post
|
||||||
if post == None:
|
|
||||||
listing = list(rkopieerpasta.top(time_filter='month', limit=250))
|
|
||||||
post = random.choice(listing)
|
|
||||||
|
|
||||||
return post
|
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command()
|
||||||
async def kopieerpasta(self, ctx):
|
async def kopieerpasta(self, ctx):
|
||||||
"""Een willekeurige shitpost"""
|
"""Een willekeurige kopieerpasta"""
|
||||||
post = self.get_kopieerpasta()
|
post = None
|
||||||
if not post:
|
for _ in range(10):
|
||||||
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()
|
post = self.get_kopieerpasta()
|
||||||
print(post.url)
|
if post and post.selftext and post.title and len(post.selftext + post.title) < 1990:
|
||||||
a += 1
|
break
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
pass #boeie
|
||||||
|
|
||||||
if len(post.selftext + post.title) < 1990:
|
if post:
|
||||||
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.")
|
||||||
|
|||||||
+61
-16
@@ -3,6 +3,7 @@ from discord.ext import commands
|
|||||||
from urllib import request
|
from urllib import request
|
||||||
import json, requests
|
import json, requests
|
||||||
import math
|
import math
|
||||||
|
from zoneinfo import ZoneInfo
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
@@ -17,6 +18,7 @@ class Shitpost(commands.Cog):
|
|||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.hdConImpatientEvents = []
|
self.hdConImpatientEvents = []
|
||||||
self.userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0'
|
self.userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0'
|
||||||
|
self.TIME_ZONE = ZoneInfo("Europe/Amsterdam")
|
||||||
try:
|
try:
|
||||||
with open('black.txt') as zwart:
|
with open('black.txt') as zwart:
|
||||||
self.zwarte_lijst = [line.rstrip('\n') for line in zwart]
|
self.zwarte_lijst = [line.rstrip('\n') for line in zwart]
|
||||||
@@ -811,23 +813,66 @@ class Shitpost(commands.Cog):
|
|||||||
await ctx.channel.send(message)
|
await ctx.channel.send(message)
|
||||||
|
|
||||||
def get_zaagmans(self):
|
def get_zaagmans(self):
|
||||||
zaagman_url = "http://iszaagmansallangsgeweest.nl/"
|
now = datetime.now(self.TIME_ZONE)
|
||||||
headers = {
|
|
||||||
'User-Agent': self.userAgent,
|
|
||||||
}
|
|
||||||
zreq = requests.get(zaagman_url, headers=headers)
|
|
||||||
if zreq:
|
|
||||||
return zreq.text.partition("<h1>")[2].partition("</h1>")[0]
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
if now.weekday() in (5, 6): # za, zo
|
||||||
|
return "Ga weekend vieren of zo."
|
||||||
|
|
||||||
|
noon_today = now.replace(hour=12, minute=0, second=0, microsecond=0)
|
||||||
|
if now.weekday() == 2 and now >= noon_today: # als woensdag na 12:00
|
||||||
|
return "Zaagmans heeft de week doormidden gezaagd!"
|
||||||
|
|
||||||
|
# tijd tot volgende woensdag 12:00. % 7 wraps als al geweest die week. vb zondag 6; (-4 % 7 = 3 dagen)
|
||||||
|
zaagmans_o_clock = noon_today + timedelta(days=(2 - now.weekday()) % 7)
|
||||||
|
if zaagmans_o_clock <= now:
|
||||||
|
zaagmans_o_clock += timedelta(days=7)
|
||||||
|
time_til_zaagmans = zaagmans_o_clock - now
|
||||||
|
|
||||||
|
if time_til_zaagmans <= timedelta(hours=5):
|
||||||
|
return "Zaagmans komt bijna, nog even geduld!" # I'm epsilon there!
|
||||||
|
|
||||||
|
whole_days = time_til_zaagmans.days
|
||||||
|
extra_hours = time_til_zaagmans.seconds // 3600
|
||||||
|
day_suffix = ""
|
||||||
|
if whole_days != 1:
|
||||||
|
day_suffix = "en"
|
||||||
|
if whole_days == 0:
|
||||||
|
time_to_wait = "minder dan 1 dag"
|
||||||
|
elif extra_hours >= 12:
|
||||||
|
time_to_wait = f"iets minder dan {whole_days + 1} dagen"
|
||||||
|
else:
|
||||||
|
time_to_wait = f"iets meer dan {whole_days} dag{day_suffix}"
|
||||||
|
|
||||||
|
if now.weekday() in (3,4): # do, vr
|
||||||
|
return f"Zaagmans heeft de week doormidden gezaagd en komt pas weer over {time_to_wait}."
|
||||||
|
else: # ma, di, wo tot 7:00
|
||||||
|
return f"Helaas, meneer Zaagmans is nog niet langsgeweest om de week doormidden te zagen. Nog {time_to_wait} wachten."
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
async def zaagmans(self, ctx):
|
async def zaagmans(self, ctx):
|
||||||
"""Is zaagmans al langsgeweest? Is de week al doormidden. Wie weet."""
|
"""Is zaagmans al langsgeweest? Is de week al doormidden. Wie weet."""
|
||||||
gezaagd = self.get_zaagmans()
|
message = ctx.author.mention + ": " + self.get_zaagmans()
|
||||||
message = ctx.author.mention + ": "
|
|
||||||
if gezaagd:
|
|
||||||
message += gezaagd
|
|
||||||
else:
|
|
||||||
message += "De waarheid over zaagmans is niet te doorgronden."
|
|
||||||
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