Compare commits
23
Commits
kankerhomo
...
566704387d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
566704387d | ||
|
|
6fe6a756bb | ||
|
|
7be76c00c3 | ||
|
|
67a82abaca | ||
|
|
9d4ffc8eff | ||
|
|
63ec2142ac | ||
|
|
f0897467d0 | ||
|
|
70e462e8f8 | ||
|
|
e184267eca | ||
|
|
53fde8c8c5 | ||
|
|
16cf8c673b | ||
|
|
2ebde2e4db | ||
|
|
65088fc69d | ||
|
|
002be0b882 | ||
|
|
8517f544d5 | ||
|
|
925e908865 | ||
|
|
ce23527eee | ||
|
|
84287234e2 | ||
|
|
56f90e7829 | ||
|
|
38877451c5 | ||
|
|
b3efbaa291 | ||
|
|
896bc3afd7 | ||
|
|
99513b16d4 |
No files matched your search
+837
-503
File diff suppressed because it is too large.
Load diff
+16
-26
@@ -14,12 +14,12 @@ class General(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.muzak_url = 'http://muzak.hoekveen.net:8001'
|
||||
self.r = praw.Reddit(
|
||||
self.reddit = praw.Reddit(
|
||||
user_agent='StroopwafelBot',
|
||||
client_secret=os.getenv("STROOP_REDDIT_SECRET"),
|
||||
client_id=os.getenv("STROOP_REDDIT_ID")
|
||||
)
|
||||
self.r.read_only = True
|
||||
self.reddit.read_only = True
|
||||
warnings.simplefilter("ignore")
|
||||
|
||||
def get_emoji_embed(self, tag: str):
|
||||
@@ -43,7 +43,7 @@ class General(commands.Cog):
|
||||
await ctx.channel.send(ctx.author.mention, embed=em)
|
||||
|
||||
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'))
|
||||
return random.choice(listing)
|
||||
|
||||
@@ -58,39 +58,29 @@ class General(commands.Cog):
|
||||
await ctx.channel.send(ctx.author.mention + ' ' + post.url)
|
||||
|
||||
def get_kopieerpasta(self):
|
||||
rkopieerpasta = self.r.subreddit('kopieerpasta')
|
||||
rkopieerpasta = self.reddit.subreddit('kopieerpasta')
|
||||
try:
|
||||
post = rkopieerpasta.random()
|
||||
|
||||
# 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
|
||||
post = random.choice(list(rkopieerpasta.top(time_filter='year', limit=100)))
|
||||
if post != None:
|
||||
return post
|
||||
except:
|
||||
return None
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
@commands.command()
|
||||
async def kopieerpasta(self, ctx):
|
||||
"""Een willekeurige shitpost"""
|
||||
post = self.get_kopieerpasta()
|
||||
if not post:
|
||||
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:
|
||||
"""Een willekeurige kopieerpasta"""
|
||||
post = None
|
||||
for _ in range(10):
|
||||
post = self.get_kopieerpasta()
|
||||
print(post.url)
|
||||
a += 1
|
||||
if post and post.selftext and post.title and len(post.selftext + post.title) < 1990:
|
||||
break
|
||||
|
||||
try:
|
||||
await ctx.message.delete()
|
||||
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+'```')
|
||||
else:
|
||||
await ctx.channel.send("Geen kopieerpasta voor jou vandaag.")
|
||||
|
||||
@@ -1,284 +1,317 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from pprint import pprint
|
||||
import time
|
||||
import numpy as np
|
||||
import random
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class Points(commands.Cog):
|
||||
"""Geef elkaar punten!"""
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.voice_states = {}
|
||||
|
||||
self.BANK_ID = 42
|
||||
self.init()
|
||||
|
||||
self.pointsCount = {}
|
||||
self.reloadPointsCount()
|
||||
|
||||
def __check(self, ctx):
|
||||
return True
|
||||
|
||||
@commands.command(pass_context=True, hidden=False)
|
||||
async def geefpunten(self, ctx, user, points: int):
|
||||
"""Wees eens lief. Geef iemand wat punten.
|
||||
Bijvoorbeeld:
|
||||
!geefpunten @ikbenjp 42
|
||||
Let op: je moet iemand taggen om punten uit te delen
|
||||
De eerste 10 punten zijn on the house. (Als er genoeg in de bank zit.)
|
||||
"""
|
||||
|
||||
self.reloadPointsCount()
|
||||
|
||||
if points == 0:
|
||||
await ctx.channel.send("0 punten? Gul hoor.")
|
||||
return
|
||||
if points < 0:
|
||||
await self.sendErrorDm(ctx, "Daar hebben we de !neempunten functie voor. Voor meer info typ: ```!help neempunten```")
|
||||
return
|
||||
|
||||
if user[0:2] != "<@":
|
||||
await self.sendErrorDm(ctx, "Je moet iemand taggen om punten te geven. :)")
|
||||
#TODO ook userId oid toestaan?
|
||||
return
|
||||
"""Geef elkaar punten!"""
|
||||
|
||||
userObj = ctx.message.mentions[0]
|
||||
|
||||
if userObj.id == ctx.author.id:
|
||||
await ctx.channel.send("Nee. Je mag niet jezelf punten geven.")
|
||||
time.sleep(0.6)
|
||||
await ctx.channel.send("Gekkie.")
|
||||
return
|
||||
if not self.isUserOnList(userObj):
|
||||
await ctx.channel.send("Nee. Die krijgt geen punten.")
|
||||
return
|
||||
if self.getUserBalance(ctx.author) < points:
|
||||
await ctx.channel.send("Daar heb jij niet genoeg puntjes voor. :bell:")
|
||||
return
|
||||
|
||||
# Execute the transaction:
|
||||
self.execute_geefpunten(ctx.author.id, userObj.id, points)
|
||||
|
||||
self.savePointsCount()
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.voice_states = {}
|
||||
|
||||
message = self.getMessageForAwardingPoints(ctx.author.name, userObj.name, points)
|
||||
await ctx.channel.send(message)
|
||||
|
||||
def execute_geefpunten(self, giverId, recieverId, points):
|
||||
# First, try to give away (at most 10) bankpoints
|
||||
areBeingGivenFromBank = min(points, self.getUsersRemainingBankPointsToGiveAwayToday(giverId))
|
||||
areBeingGivenFromBank = min(areBeingGivenFromBank, self.getBankBalance())
|
||||
if areBeingGivenFromBank > 0:
|
||||
self.transferPoints(self.BANK_ID, recieverId, areBeingGivenFromBank)
|
||||
self.increaseUsersBankPointGivenAwayToday(giverId, areBeingGivenFromBank)
|
||||
remainingPointsToGive = points - areBeingGivenFromBank
|
||||
else:
|
||||
remainingPointsToGive = points
|
||||
# The remaining points come out of your own pocket
|
||||
if remainingPointsToGive > 0:
|
||||
self.transferPoints(giverId, recieverId, remainingPointsToGive)
|
||||
|
||||
|
||||
@commands.command(pass_context=True, hidden=False)
|
||||
async def neempunten(self, ctx, user, points: int):
|
||||
"""Tijd om iemand the shamen. Haal wat punten weg.
|
||||
Bijvoorbeeld:
|
||||
!neempunten @mark 5
|
||||
Punten gaan naar de bank. Je mag niet meer dan 10 punten per dag afnemen.
|
||||
Let op: je moet iemand taggen om punten weg te nemen.
|
||||
"""
|
||||
|
||||
self.reloadPointsCount()
|
||||
|
||||
if points < 1:
|
||||
await ctx.channel.send("Volgens mij snap je het niet.")
|
||||
return
|
||||
if points > 10:
|
||||
await self.sendErrorDm(ctx, "Je mag niet meer dan 10 punten afnemen.")
|
||||
return
|
||||
remainingToTakeAway = self.getUsersRemainingPointsToTakeToday(ctx.author.id)
|
||||
if points > remainingToTakeAway: # The limit per day is 10
|
||||
await self.sendErrorDm(ctx, "Je mag vandaag nog maar " + str(remainingToTakeAway) + " punten wegnemen.")
|
||||
return
|
||||
|
||||
if user[0:2] != "<@":
|
||||
await self.sendErrorDm(ctx, "Je moet iemand taggen. :)")
|
||||
return
|
||||
|
||||
userObj = ctx.message.mentions[0]
|
||||
|
||||
if not self.isUserOnList(userObj):
|
||||
await ctx.channel.send("Nee.")
|
||||
return
|
||||
if self.getUserBalance(userObj) < points:
|
||||
await ctx.channel.send(userObj.name + " mag niet rood staan.")
|
||||
return
|
||||
|
||||
# Execute the transaction:
|
||||
self.execute_neempunten(ctx.author.id, userObj.id, points);
|
||||
|
||||
self.savePointsCount()
|
||||
self.BANK_ID = 42
|
||||
self.init()
|
||||
|
||||
message = self.getMessageForTakingPoints(userObj.name, ctx.author.name, points)
|
||||
await ctx.channel.send(message)
|
||||
|
||||
def execute_neempunten(self, takerId, victimId, points):
|
||||
self.increaseUsersPointTakenOnDate(takerId, points)
|
||||
self.transferPoints(victimId, self.BANK_ID, points)
|
||||
|
||||
|
||||
@commands.command(pass_context=True, hidden=False)
|
||||
async def puntentelling(self, ctx):
|
||||
"""Hoeveel punten heeft iedereen?
|
||||
"""
|
||||
|
||||
self.reloadPointsCount()
|
||||
|
||||
message = "**De puntentelling:** \n```"
|
||||
pointsCountSorted = sorted(self.pointsCount.items(), key=lambda i: i[1]['points'], reverse=True)
|
||||
for user in pointsCountSorted:
|
||||
if user[0] != self.BANK_ID:
|
||||
message += str(user[1]["points"]).rjust(4) + " " + user[1]["name"] + "\n"
|
||||
message += str(self.pointsCount[self.BANK_ID]["points"]).rjust(4) + " " + self.pointsCount[self.BANK_ID]["name"] + "```"
|
||||
await ctx.channel.send(message)
|
||||
|
||||
|
||||
# No public shaming. Send somebody a direct correction message.
|
||||
async def sendErrorDm(self, ctx, message):
|
||||
try:
|
||||
await ctx.message.delete()
|
||||
except:
|
||||
print("No permission to delete message")
|
||||
try:
|
||||
await ctx.message.author.send(message)
|
||||
except:
|
||||
print("No permission to send DM")
|
||||
|
||||
|
||||
# Get the points count object from the file
|
||||
def reloadPointsCount(self):
|
||||
self.pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
|
||||
# Save the points count to the file
|
||||
def savePointsCount(self):
|
||||
np.save("pointscount.npy", self.pointsCount)
|
||||
|
||||
# Transfer points form one user to another
|
||||
def transferPoints(self, fromUserId, toUserId, points):
|
||||
self.pointsCount[fromUserId]["points"] -= points
|
||||
self.pointsCount[toUserId]["points"] += points
|
||||
|
||||
# Do we know this user?
|
||||
def isUserOnList(self, user):
|
||||
return user.id in self.pointsCount.keys()
|
||||
|
||||
# Get a user's point balance
|
||||
def getUserBalance(self, user):
|
||||
return self.pointsCount[user.id]["points"]
|
||||
|
||||
# Get the balance of the bank
|
||||
def getBankBalance(self):
|
||||
return self.pointsCount[self.BANK_ID]["points"]
|
||||
|
||||
# To keep track if a user used some points today, we look at when the last time was he/she used them
|
||||
# If this was in the past: reset
|
||||
# Also, return the updated object. Why not.
|
||||
def refreshDateVarsAndReturnUserVars(self, userId):
|
||||
currentDateStr = datetime.now().strftime("%Y%m%d")
|
||||
if self.pointsCount[userId]["theDate"] != currentDateStr:
|
||||
self.pointsCount[userId]["theDate"] = currentDateStr
|
||||
self.pointsCount[userId]["pointTakenOnDate"] = 0
|
||||
self.pointsCount[userId]["bankPointsGivenOnDate"] = 0
|
||||
return self.pointsCount[userId]
|
||||
|
||||
# How many points can this user still take away today?
|
||||
def getUsersRemainingPointsToTakeToday(self, userId):
|
||||
userInfo = self.refreshDateVarsAndReturnUserVars(userId)
|
||||
return 10 - userInfo["pointTakenOnDate"]
|
||||
|
||||
# How many bank points can this user still give away?
|
||||
def getUsersRemainingBankPointsToGiveAwayToday(self, userId):
|
||||
userInfo = self.refreshDateVarsAndReturnUserVars(userId)
|
||||
return 10 - userInfo["bankPointsGivenOnDate"]
|
||||
|
||||
# Increase the number of points this user has taken away today.
|
||||
# Warning: assumes you executed refreshDateVarsAndReturnUserVars()
|
||||
def increaseUsersPointTakenOnDate(self, userId, points):
|
||||
self.pointsCount[userId]["pointTakenOnDate"] += points
|
||||
|
||||
# Increase the number of bank points this user has given today
|
||||
# Warning: assumes you executed refreshDateVarsAndReturnUserVars()
|
||||
def increaseUsersBankPointGivenAwayToday(self, userId, points):
|
||||
self.pointsCount[userId]["bankPointsGivenOnDate"] += points
|
||||
self.pointsCount = {}
|
||||
self.reloadPointsCount()
|
||||
|
||||
|
||||
# Generate a semi-random text to tell somebody they got some shiny new points
|
||||
def getMessageForAwardingPoints(self, userNameFrom: str, userNameTo: str, points: int):
|
||||
p = str(points)
|
||||
|
||||
if points == 1:
|
||||
grammarFixer = {"suffixGb":"", "suffixNl":"", "zijnOfIs": "is"}
|
||||
else:
|
||||
grammarFixer = {"suffixGb":"s", "suffixNl":"en", "zijnOfIs": "zijn"}
|
||||
|
||||
messages = [
|
||||
p + " punt" + grammarFixer["suffixNl"] + " voor " + userNameTo + ".",
|
||||
userNameTo + " krijgt " + p + " punt" + grammarFixer["suffixNl"] + ".",
|
||||
userNameTo + " krijgt " + p + " punt" + grammarFixer["suffixNl"] + " van " + userNameFrom,
|
||||
p + " POINT" + grammarFixer["suffixGb"].upper() + " TO GRYFFINDO.. oh.. " + userNameTo + ".",
|
||||
userNameTo + ", jij krijgt " + p + " puntje" + grammarFixer["suffixGb"] + " van " + userNameFrom + ". Lief he? :heart:",
|
||||
"+" + p + " punt" + grammarFixer["suffixNl"] + " voor " + userNameTo + "! Highscore!",
|
||||
userNameTo + ", alsjeblieft, " + p + " punt" + grammarFixer["suffixNl"] + ".",
|
||||
"Hier " + grammarFixer["zijnOfIs"] + " " + p + " punt" + grammarFixer["suffixNl"] + ", " + userNameTo + ". Don't spend it all in one place...",
|
||||
"Jij kan wel " + p + " punt" + grammarFixer["suffixNl"] + " gebruiken, " + userNameTo + ".",
|
||||
p + " blockchain smartcontract punt" + grammarFixer["suffixNl"] + " voor " + userNameTo + ". :rocket: "
|
||||
]
|
||||
return messages[random.randint(0, len(messages)-1)]
|
||||
|
||||
# Generate a semi-random text to tell somebody they just lost their precious points
|
||||
def getMessageForTakingPoints(self, userNameFrom: str, userNameTaker: str, points: int):
|
||||
p = str(points)
|
||||
|
||||
if points == 1:
|
||||
grammarFixer = {"suffixGb":"", "suffixNl":"", "gaatOfGaan":"gaat"}
|
||||
else:
|
||||
grammarFixer = {"suffixGb":"s", "suffixNl":"en", "gaatOfGaan":"gaan"}
|
||||
|
||||
messages = [
|
||||
userNameFrom + " verliest " + p + " punt" + grammarFixer["suffixNl"] + ".",
|
||||
userNameFrom + " is " + p + " punt" + grammarFixer["suffixNl"] + " kwijt. F.",
|
||||
userNameTaker + " vindt dat jij " + p + " punt" + grammarFixer["suffixNl"] + " moet kwijtraken, " + userNameFrom + ".",
|
||||
p + " POINT" + grammarFixer["suffixGb"].upper() + " FROM HUFFELPU.. oh.. " + userNameFrom + ".",
|
||||
"Je bent " + p + " punt" + grammarFixer["suffixNl"] + " armer geworden, " + userNameFrom + ".",
|
||||
"Je hebt toch genoeg, " + userNameFrom + ". We halen " + p + " punt" + grammarFixer["suffixNl"] + " weg.",
|
||||
userNameTaker + " haalt " + p + " punt" + grammarFixer["suffixNl"] + " weg bij " + userNameFrom + ". Wat een lul.",
|
||||
p + " punt" + grammarFixer["suffixNl"] + " " + grammarFixer["gaatOfGaan"] + " van " + userNameFrom + " naar de bank."
|
||||
]
|
||||
return messages[random.randint(0, len(messages)-1)]
|
||||
|
||||
|
||||
def init(self):
|
||||
# Check if points file exists:
|
||||
try:
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
except FileNotFoundError:
|
||||
np.save("pointscount.npy", {})
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
|
||||
# Initialise the bank:
|
||||
if self.BANK_ID not in pointsCount.keys():
|
||||
pointsCount[self.BANK_ID] = {"name": '"De Bank"', "points": 300}
|
||||
np.save("pointscount.npy", pointsCount)
|
||||
|
||||
# Add new/unknown members:
|
||||
list_channel = self.bot.get_channel(int(os.getenv('STROOP_CHANNEL_SHITPOST')))
|
||||
memberList = list_channel.members if list_channel else []
|
||||
for member in memberList:
|
||||
# Give new members 100 points
|
||||
if member.id not in pointsCount.keys() and not member.bot:
|
||||
pointsCount[member.id] = {"name": member.name, "points": 100, "pointTakenOnDate":0, "bankPointsGivenOnDate":0, "theDate":"20181231"}
|
||||
np.save("pointscount.npy", pointsCount)
|
||||
def __check(self, ctx):
|
||||
return True
|
||||
|
||||
@commands.command()
|
||||
async def geefpunten(self, ctx, *args):
|
||||
"""Wees eens lief. Geef iemand wat punten.
|
||||
Bijvoorbeeld:
|
||||
!geefpunten @ikbenjp 42 of !geefpunten 42 @ikbenjp
|
||||
Let op: je moet iemand taggen om punten uit te delen
|
||||
De eerste 10 punten zijn on the house. (Als er genoeg in de bank zit.)
|
||||
"""
|
||||
|
||||
if not ctx.message.mentions: #als er uberhaupt geen mention is zijn we snel klaar
|
||||
await ctx.send(f"{ctx.author.mention} je moet iemand taggen om punten te geven. :)")
|
||||
return
|
||||
|
||||
if len(args) == 2:
|
||||
user = None
|
||||
points = None
|
||||
for arg in args[0:2]:
|
||||
if arg[0:2] == "<@":
|
||||
user = arg #doen we verder niks mee, maar zo bepalen we positie van de puntjes
|
||||
else:
|
||||
try:
|
||||
points = int(arg)
|
||||
except ValueError:
|
||||
pass #dealen we hieronder mee
|
||||
|
||||
if user == None or points == None:
|
||||
raise commands.BadArgument("Verkeerd type argumenten")
|
||||
else:
|
||||
raise commands.BadArgument("Verkeerd aantal argumenten")
|
||||
|
||||
self.reloadPointsCount()
|
||||
|
||||
if points == 0:
|
||||
await ctx.channel.send("0 punten? Gul hoor.")
|
||||
return
|
||||
if points < 0:
|
||||
await self.sendErrorDm(ctx, "Daar hebben we de !neempunten functie voor. Voor meer info typ: ```!help neempunten```")
|
||||
return
|
||||
|
||||
userObj = ctx.message.mentions[0]
|
||||
|
||||
if userObj.id == ctx.author.id:
|
||||
await ctx.channel.send("Nee. Je mag niet jezelf punten geven.")
|
||||
time.sleep(0.6)
|
||||
await ctx.channel.send("Gekkie.")
|
||||
return
|
||||
if not self.isUserOnList(userObj):
|
||||
await ctx.channel.send("Nee. Die krijgt geen punten.")
|
||||
return
|
||||
if self.getUserBalance(ctx.author) < points:
|
||||
await ctx.channel.send("Daar heb jij niet genoeg puntjes voor. :bell:")
|
||||
return
|
||||
|
||||
# Execute the transaction:
|
||||
self.execute_geefpunten(ctx.author.id, userObj.id, points)
|
||||
|
||||
self.savePointsCount()
|
||||
|
||||
message = self.getMessageForAwardingPoints(ctx.author.name, userObj.name, points)
|
||||
await ctx.channel.send(message)
|
||||
|
||||
def execute_geefpunten(self, giverId, recieverId, points):
|
||||
# First, try to give away (at most 10) bankpoints
|
||||
areBeingGivenFromBank = min(points, self.getUsersRemainingBankPointsToGiveAwayToday(giverId))
|
||||
areBeingGivenFromBank = min(areBeingGivenFromBank, self.getBankBalance())
|
||||
if areBeingGivenFromBank > 0:
|
||||
self.transferPoints(self.BANK_ID, recieverId, areBeingGivenFromBank)
|
||||
self.increaseUsersBankPointGivenAwayToday(giverId, areBeingGivenFromBank)
|
||||
remainingPointsToGive = points - areBeingGivenFromBank
|
||||
else:
|
||||
remainingPointsToGive = points
|
||||
# The remaining points come out of your own pocket
|
||||
if remainingPointsToGive > 0:
|
||||
self.transferPoints(giverId, recieverId, remainingPointsToGive)
|
||||
|
||||
|
||||
@commands.command()
|
||||
async def neempunten(self, ctx, *args):
|
||||
"""Tijd om iemand the shamen. Haal wat punten weg.
|
||||
Bijvoorbeeld:
|
||||
!neempunten @mark 5 of !neempunten 5 @mark
|
||||
Punten gaan naar de bank. Je mag niet meer dan 10 punten per dag afnemen.
|
||||
Let op: je moet iemand taggen om punten weg te nemen.
|
||||
"""
|
||||
|
||||
if not ctx.message.mentions: #als er uberhaupt geen mention is zijn we snel klaar
|
||||
await ctx.send(f"{ctx.author.mention} je moet iemand taggen om punten af te nemen. :)")
|
||||
return
|
||||
|
||||
if len(args) == 2:
|
||||
user = None
|
||||
points = None
|
||||
for arg in args[0:2]:
|
||||
if arg[0:2] == "<@":
|
||||
user = arg #doen we verder niks mee, maar zo bepalen we positie van de puntjes
|
||||
else:
|
||||
try:
|
||||
points = int(arg)
|
||||
except ValueError:
|
||||
pass #dealen we hieronder mee
|
||||
|
||||
if user == None or points == None:
|
||||
raise commands.BadArgument("Verkeerd type argumenten")
|
||||
else:
|
||||
raise commands.BadArgument("Verkeerd aantal argumenten")
|
||||
|
||||
self.reloadPointsCount()
|
||||
|
||||
if points < 1:
|
||||
await ctx.channel.send("Volgens mij snap je het niet.")
|
||||
return
|
||||
if points > 10:
|
||||
await self.sendErrorDm(ctx, "Je mag niet meer dan 10 punten afnemen.")
|
||||
return
|
||||
remainingToTakeAway = self.getUsersRemainingPointsToTakeToday(ctx.author.id)
|
||||
if points > remainingToTakeAway: # The limit per day is 10
|
||||
await self.sendErrorDm(ctx, "Je mag vandaag nog maar " + str(remainingToTakeAway) + " punten wegnemen.")
|
||||
return
|
||||
|
||||
userObj = ctx.message.mentions[0]
|
||||
|
||||
if not self.isUserOnList(userObj):
|
||||
await ctx.channel.send("Nee.")
|
||||
return
|
||||
if self.getUserBalance(userObj) < points:
|
||||
await ctx.channel.send(userObj.name + " mag niet rood staan.")
|
||||
return
|
||||
|
||||
# Execute the transaction:
|
||||
self.execute_neempunten(ctx.author.id, userObj.id, points);
|
||||
|
||||
self.savePointsCount()
|
||||
|
||||
message = self.getMessageForTakingPoints(userObj.name, ctx.author.name, points)
|
||||
await ctx.channel.send(message)
|
||||
|
||||
def execute_neempunten(self, takerId, victimId, points):
|
||||
self.increaseUsersPointTakenOnDate(takerId, points)
|
||||
self.transferPoints(victimId, self.BANK_ID, points)
|
||||
|
||||
|
||||
@commands.command(pass_context=True, hidden=False)
|
||||
async def puntentelling(self, ctx):
|
||||
"""Hoeveel punten heeft iedereen?
|
||||
"""
|
||||
|
||||
self.reloadPointsCount()
|
||||
|
||||
message = "**De puntentelling:** \n```"
|
||||
pointsCountSorted = sorted(self.pointsCount.items(), key=lambda i: i[1]['points'], reverse=True)
|
||||
for user in pointsCountSorted:
|
||||
if user[0] != self.BANK_ID:
|
||||
message += str(user[1]["points"]).rjust(4) + " " + user[1]["name"] + "\n"
|
||||
message += str(self.pointsCount[self.BANK_ID]["points"]).rjust(4) + " " + self.pointsCount[self.BANK_ID]["name"] + "```"
|
||||
await ctx.channel.send(message)
|
||||
|
||||
|
||||
# No public shaming. Send somebody a direct correction message.
|
||||
async def sendErrorDm(self, ctx, message):
|
||||
try:
|
||||
await ctx.message.delete()
|
||||
except:
|
||||
print("No permission to delete message")
|
||||
try:
|
||||
await ctx.message.author.send(message)
|
||||
except:
|
||||
print("No permission to send DM")
|
||||
|
||||
|
||||
# Get the points count object from the file
|
||||
def reloadPointsCount(self):
|
||||
self.pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
|
||||
# Save the points count to the file
|
||||
def savePointsCount(self):
|
||||
np.save("pointscount.npy", self.pointsCount)
|
||||
|
||||
# Transfer points form one user to another
|
||||
def transferPoints(self, fromUserId, toUserId, points):
|
||||
self.pointsCount[fromUserId]["points"] -= points
|
||||
self.pointsCount[toUserId]["points"] += points
|
||||
|
||||
# Do we know this user?
|
||||
def isUserOnList(self, user):
|
||||
return user.id in self.pointsCount.keys()
|
||||
|
||||
# Get a user's point balance
|
||||
def getUserBalance(self, user):
|
||||
return self.pointsCount[user.id]["points"]
|
||||
|
||||
# Get the balance of the bank
|
||||
def getBankBalance(self):
|
||||
return self.pointsCount[self.BANK_ID]["points"]
|
||||
|
||||
# To keep track if a user used some points today, we look at when the last time was he/she used them
|
||||
# If this was in the past: reset
|
||||
# Also, return the updated object. Why not.
|
||||
def refreshDateVarsAndReturnUserVars(self, userId):
|
||||
currentDateStr = datetime.now().strftime("%Y%m%d")
|
||||
if self.pointsCount[userId]["theDate"] != currentDateStr:
|
||||
self.pointsCount[userId]["theDate"] = currentDateStr
|
||||
self.pointsCount[userId]["pointTakenOnDate"] = 0
|
||||
self.pointsCount[userId]["bankPointsGivenOnDate"] = 0
|
||||
return self.pointsCount[userId]
|
||||
|
||||
# How many points can this user still take away today?
|
||||
def getUsersRemainingPointsToTakeToday(self, userId):
|
||||
userInfo = self.refreshDateVarsAndReturnUserVars(userId)
|
||||
return 10 - userInfo["pointTakenOnDate"]
|
||||
|
||||
# How many bank points can this user still give away?
|
||||
def getUsersRemainingBankPointsToGiveAwayToday(self, userId):
|
||||
userInfo = self.refreshDateVarsAndReturnUserVars(userId)
|
||||
return 10 - userInfo["bankPointsGivenOnDate"]
|
||||
|
||||
# Increase the number of points this user has taken away today.
|
||||
# Warning: assumes you executed refreshDateVarsAndReturnUserVars()
|
||||
def increaseUsersPointTakenOnDate(self, userId, points):
|
||||
self.pointsCount[userId]["pointTakenOnDate"] += points
|
||||
|
||||
# Increase the number of bank points this user has given today
|
||||
# Warning: assumes you executed refreshDateVarsAndReturnUserVars()
|
||||
def increaseUsersBankPointGivenAwayToday(self, userId, points):
|
||||
self.pointsCount[userId]["bankPointsGivenOnDate"] += points
|
||||
|
||||
|
||||
# Generate a semi-random text to tell somebody they got some shiny new points
|
||||
def getMessageForAwardingPoints(self, userNameFrom: str, userNameTo: str, points: int):
|
||||
p = str(points)
|
||||
|
||||
if points == 1:
|
||||
grammarFixer = {"suffixGb":"", "suffixNl":"", "zijnOfIs": "is"}
|
||||
else:
|
||||
grammarFixer = {"suffixGb":"s", "suffixNl":"en", "zijnOfIs": "zijn"}
|
||||
|
||||
messages = [
|
||||
p + " punt" + grammarFixer["suffixNl"] + " voor " + userNameTo + ".",
|
||||
userNameTo + " krijgt " + p + " punt" + grammarFixer["suffixNl"] + ".",
|
||||
userNameTo + " krijgt " + p + " punt" + grammarFixer["suffixNl"] + " van " + userNameFrom,
|
||||
p + " POINT" + grammarFixer["suffixGb"].upper() + " TO GRYFFINDO.. oh.. " + userNameTo + ".",
|
||||
userNameTo + ", jij krijgt " + p + " puntje" + grammarFixer["suffixGb"] + " van " + userNameFrom + ". Lief he? :heart:",
|
||||
"+" + p + " punt" + grammarFixer["suffixNl"] + " voor " + userNameTo + "! Highscore!",
|
||||
userNameTo + ", alsjeblieft, " + p + " punt" + grammarFixer["suffixNl"] + ".",
|
||||
"Hier " + grammarFixer["zijnOfIs"] + " " + p + " punt" + grammarFixer["suffixNl"] + ", " + userNameTo + ". Don't spend it all in one place...",
|
||||
"Jij kan wel " + p + " punt" + grammarFixer["suffixNl"] + " gebruiken, " + userNameTo + ".",
|
||||
p + " blockchain smartcontract punt" + grammarFixer["suffixNl"] + " voor " + userNameTo + ". :rocket: "
|
||||
]
|
||||
return messages[random.randint(0, len(messages)-1)]
|
||||
|
||||
# Generate a semi-random text to tell somebody they just lost their precious points
|
||||
def getMessageForTakingPoints(self, userNameFrom: str, userNameTaker: str, points: int):
|
||||
p = str(points)
|
||||
|
||||
if points == 1:
|
||||
grammarFixer = {"suffixGb":"", "suffixNl":"", "gaatOfGaan":"gaat"}
|
||||
else:
|
||||
grammarFixer = {"suffixGb":"s", "suffixNl":"en", "gaatOfGaan":"gaan"}
|
||||
|
||||
messages = [
|
||||
userNameFrom + " verliest " + p + " punt" + grammarFixer["suffixNl"] + ".",
|
||||
userNameFrom + " is " + p + " punt" + grammarFixer["suffixNl"] + " kwijt. F.",
|
||||
userNameTaker + " vindt dat jij " + p + " punt" + grammarFixer["suffixNl"] + " moet kwijtraken, " + userNameFrom + ".",
|
||||
p + " POINT" + grammarFixer["suffixGb"].upper() + " FROM HUFFELPU.. oh.. " + userNameFrom + ".",
|
||||
"Je bent " + p + " punt" + grammarFixer["suffixNl"] + " armer geworden, " + userNameFrom + ".",
|
||||
"Je hebt toch genoeg, " + userNameFrom + ". We halen " + p + " punt" + grammarFixer["suffixNl"] + " weg.",
|
||||
userNameTaker + " haalt " + p + " punt" + grammarFixer["suffixNl"] + " weg bij " + userNameFrom + ". Wat een lul.",
|
||||
p + " punt" + grammarFixer["suffixNl"] + " " + grammarFixer["gaatOfGaan"] + " van " + userNameFrom + " naar de bank."
|
||||
]
|
||||
return messages[random.randint(0, len(messages)-1)]
|
||||
|
||||
|
||||
def init(self):
|
||||
# Check if points file exists:
|
||||
try:
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
except FileNotFoundError:
|
||||
np.save("pointscount.npy", {})
|
||||
pointsCount = np.load('pointscount.npy', allow_pickle=True).item()
|
||||
|
||||
# Initialise the bank:
|
||||
if self.BANK_ID not in pointsCount.keys():
|
||||
pointsCount[self.BANK_ID] = {"name": '"De Bank"', "points": 300}
|
||||
np.save("pointscount.npy", pointsCount)
|
||||
|
||||
# Add new/unknown members:
|
||||
list_channel = self.bot.get_channel(int(os.getenv('STROOP_CHANNEL_SHITPOST')))
|
||||
memberList = list_channel.members if list_channel else []
|
||||
for member in memberList:
|
||||
# Give new members 100 points
|
||||
if member.id not in pointsCount.keys() and not member.bot:
|
||||
pointsCount[member.id] = {"name": member.name, "points": 100, "pointTakenOnDate":0, "bankPointsGivenOnDate":0, "theDate":"20181231"}
|
||||
np.save("pointscount.npy", pointsCount)
|
||||
+115
-70
@@ -3,6 +3,7 @@ from discord.ext import commands
|
||||
from urllib import request
|
||||
import json, requests
|
||||
import math
|
||||
from zoneinfo import ZoneInfo
|
||||
from datetime import datetime, timedelta
|
||||
import os
|
||||
import random
|
||||
@@ -12,11 +13,12 @@ import re
|
||||
|
||||
class Shitpost(commands.Cog):
|
||||
"""Schijtpaal commando's. Alleen bruikbaar in de daarvoor toegewezen schijtpaal kanalen."""
|
||||
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.hdConImpatientEvents = []
|
||||
self.userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0'
|
||||
self.TIME_ZONE = ZoneInfo("Europe/Amsterdam")
|
||||
try:
|
||||
with open('black.txt') as zwart:
|
||||
self.zwarte_lijst = [line.rstrip('\n') for line in zwart]
|
||||
@@ -25,7 +27,7 @@ class Shitpost(commands.Cog):
|
||||
except:
|
||||
self.zwarte_lijst = ["___", "___, ___", "___, ___, ___"]
|
||||
self.witte_lijst = ["A", "B", "C"]
|
||||
self.insult = ['kankerhomo', 'koekenbakker','stumperd','knurft','oelewapper','klungel','stoethaspel',
|
||||
self.insult = ['koekenbakker','stumperd','knurft','oelewapper','klungel','stoethaspel',
|
||||
'onnozelaar','beunhaas','uilskuiken','bamibal','zwakzinnige','oenemeloen',
|
||||
'klaphark','rompeknonker','bal gehakt','ongewassen vlerk','droeftoeter','omgedraaid pak hagelslag',
|
||||
'prutser','domkop','non-valeur','ontzettende debiel','paljas','simpeltje',
|
||||
@@ -45,7 +47,7 @@ class Shitpost(commands.Cog):
|
||||
self.HdConDate = None
|
||||
if datestring:
|
||||
self.HdConDate = datetime.fromisoformat(datestring)
|
||||
|
||||
|
||||
@commands.command(pass_context=True, hidden=False)
|
||||
async def ishetalhdcon(self, ctx):
|
||||
"""Hoe lang nog tot Hoestende Draken Con dit jaar? Of is het pas volgend jaar?
|
||||
@@ -71,7 +73,7 @@ class Shitpost(commands.Cog):
|
||||
|
||||
NachtjesSlapen = Distance.days + 1
|
||||
Message = f"Nog {NachtjesSlapen} nachtje{'s' if NachtjesSlapen > 1 else ''} slapen..."
|
||||
|
||||
|
||||
#Hou bij hoe vaak dit wordt gevraagd:
|
||||
eventsMinutesAgo = 0;
|
||||
eventsMinutesAgoSameAuthor = 0;
|
||||
@@ -86,7 +88,7 @@ class Shitpost(commands.Cog):
|
||||
eventsLastDays += 1
|
||||
if not "DMChannel" in type(ctx.channel).__name__: #ignore personal chats
|
||||
self.hdConImpatientEvents.append([ctx.author.id, Now])
|
||||
|
||||
|
||||
#Als dezelfde persoon het blijft vragen pikken we het niet:
|
||||
if eventsMinutesAgoSameAuthor > 3:
|
||||
return #fuck it.
|
||||
@@ -94,7 +96,7 @@ class Shitpost(commands.Cog):
|
||||
if eventsMinutesAgoSameAuthor > 2:
|
||||
await ctx.channel.send("...")
|
||||
return
|
||||
await ctx.channel.send("Dat vroeg je net ook al, " + ctx.author.mention + "!")
|
||||
await ctx.channel.send("Dat vroeg je net ook al, " + ctx.author.mention + "!")
|
||||
return
|
||||
#Hoe vaker er wordt gevraagd, hoe ongeduldiger de antwoorden:
|
||||
if not "DMChannel" in type(ctx.channel).__name__: #ignore personal chats
|
||||
@@ -107,8 +109,8 @@ class Shitpost(commands.Cog):
|
||||
Message = "Dat hebben jullie net gevraagd."
|
||||
elif impatientFactor > 12:
|
||||
Message = "Nee."
|
||||
|
||||
await ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
||||
|
||||
await ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
||||
|
||||
def zalgofy(self, sentence, factor = 4):
|
||||
random.seed(datetime.now().timestamp())
|
||||
@@ -186,27 +188,27 @@ class Shitpost(commands.Cog):
|
||||
minutes = math.floor(secondsLeft / 60)
|
||||
seconds = secondsLeft - minutes * 60
|
||||
Message += "Nog " + str(days) + " dagen, " + str(hours) + " uur, " + str(minutes) + " minuten en " + str(seconds) + " seconden tot 420!!"
|
||||
|
||||
|
||||
await ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
||||
|
||||
|
||||
@commands.command(pass_context=True, hidden=False)
|
||||
async def iselderscrolls6aluit(self, ctx):
|
||||
"""Hoe lang nog tot Elder Scrolls 6? 11-11-11? 20-20-20?
|
||||
Gebruik: !iselderscrolls6aluit
|
||||
"""
|
||||
Now = datetime.now()
|
||||
|
||||
|
||||
if Now.month == 4 and Now.day == 1:
|
||||
Message = "JA! :hushed: " #1 april, motherfucker.
|
||||
else:
|
||||
Message = "Nee. :frowning2: Nog even geduld..."
|
||||
|
||||
await ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
||||
|
||||
await ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
||||
|
||||
def get_giet_het_oan(self):
|
||||
# Alsof we ooit nog een elfstedentocht gaan krijgen.
|
||||
return "nee"
|
||||
|
||||
|
||||
@commands.command(pass_context=True, hidden=False)
|
||||
async def giethetaloan(self, ctx):
|
||||
"""Giet het al oan?
|
||||
@@ -230,7 +232,7 @@ class Shitpost(commands.Cog):
|
||||
return inspiration.text
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@commands.command(pass_context=True, hidden=False)
|
||||
async def inspire(self, ctx):
|
||||
"""Laat je inspireren
|
||||
@@ -253,7 +255,7 @@ class Shitpost(commands.Cog):
|
||||
params = dict(
|
||||
template_id = template,
|
||||
username = 'Stroopwafel',
|
||||
password = os.getenv("STROOP_IMGFLIP_PASSWORD"),
|
||||
password = os.getenv("STROOP_IMGFLIP_PASSWORD"),
|
||||
text0 = boven,
|
||||
text1 = onder
|
||||
)
|
||||
@@ -309,7 +311,7 @@ class Shitpost(commands.Cog):
|
||||
print("No permission to delete message")
|
||||
if em:
|
||||
await ctx.channel.send(ctx.author.mention, embed=em)
|
||||
|
||||
|
||||
def get_tegeltje(self, tekst, auteur):
|
||||
params = {
|
||||
'text0': 'dummy0',
|
||||
@@ -372,7 +374,7 @@ class Shitpost(commands.Cog):
|
||||
Wie weet.
|
||||
Probeer het eens op verschillende tijdstippen.
|
||||
"""
|
||||
|
||||
|
||||
time=datetime.now().strftime('%H%M')
|
||||
for argument in args:
|
||||
time = argument
|
||||
@@ -447,7 +449,7 @@ class Shitpost(commands.Cog):
|
||||
await ctx.channel.send(message)
|
||||
else:
|
||||
await ctx.channel.send("Die roll vind ik echt een beetje te mal..")
|
||||
|
||||
|
||||
def get_weerbericht(self, wData, verbose=None):
|
||||
if not wData:
|
||||
return None
|
||||
@@ -466,8 +468,8 @@ class Shitpost(commands.Cog):
|
||||
message += self.getWeatherIconTranslation( wData["image"] )
|
||||
message += " Het is " + wData["temp"] + " graden "
|
||||
message += "en het weer is: " + wData["samenv"] + ". "
|
||||
message += "De verwachting: " + wData["verw"]
|
||||
|
||||
message += "De verwachting: " + wData["verw"]
|
||||
|
||||
if (verbose):
|
||||
# Only print tomorrow, the day after and the BBQ grade if verbose is on:
|
||||
message += "\n\nMorgen: " + self.getWeatherIconTranslation( wData["d1weer"] )
|
||||
@@ -489,13 +491,13 @@ class Shitpost(commands.Cog):
|
||||
message += "Kans op neerslag: " + wData["d2neerslag"] + "%. "
|
||||
if (int(wData["d2windk"]) > 5):
|
||||
message += "Windkracht " + wData["d2windk"] + ". "
|
||||
|
||||
|
||||
bbqGrade = self.getBbqGrade(wData)
|
||||
message += "\n\nHet BBQ cijfer voor vandaag is: " + '{0:g}'.format(round(bbqGrade, 1))
|
||||
|
||||
|
||||
message += "\n\nOant Moarn!"
|
||||
return message
|
||||
|
||||
|
||||
|
||||
def get_weer_json(self, location=None):
|
||||
if not location:
|
||||
@@ -518,7 +520,7 @@ class Shitpost(commands.Cog):
|
||||
if not wData or not message:
|
||||
message = "Weer ophalen niet gelukt. Probeer het later nogmaals.."
|
||||
await ctx.channel.send(message)
|
||||
|
||||
|
||||
#returns a nice weather icon. Sometimes the API uses non-documented icons, so we return something else
|
||||
def getWeatherIconTranslation(self, iconKey):
|
||||
WEATHER_ICONS = {
|
||||
@@ -541,7 +543,7 @@ class Shitpost(commands.Cog):
|
||||
return WEATHER_ICONS[iconKey]
|
||||
except KeyError:
|
||||
return ":park:"
|
||||
|
||||
|
||||
def getWeerAlarm(self, weatherObj):
|
||||
if (weatherObj["alarm"] != "1"):
|
||||
return None, ""
|
||||
@@ -550,7 +552,7 @@ class Shitpost(commands.Cog):
|
||||
if ("code oranje" in weatherObj["alarmtxt"].lower()):
|
||||
return "oranje", "PAS OP! :large_orange_diamond: Code Oranje :large_orange_diamond: is van kracht! <:willy:505886070668263426> " + weatherObj["alarmtxt"]
|
||||
return "geel", ":warning: Kennelijk is er een weeralarm: " + weatherObj["alarmtxt"]
|
||||
|
||||
|
||||
#determines a BBQ grade based on the current weather
|
||||
def getBbqGrade(self, weatherObj):
|
||||
grade = 1.0
|
||||
@@ -566,12 +568,12 @@ class Shitpost(commands.Cog):
|
||||
if float(weatherObj["d0neerslag"]) < 10:
|
||||
if weatherObj["image"] in ["regen", "buien", "bliksem", "hagel", "sneeuw", "halfbewolkt_regen"]:
|
||||
grade -= 2.0
|
||||
|
||||
|
||||
#remove points for very hot weather: (above 30)
|
||||
grade -= max(0, (float(weatherObj["d0tmax"]) - 30.0)/10 )
|
||||
except:
|
||||
return -1.0
|
||||
|
||||
|
||||
return max(1.0, min(10.0, grade))
|
||||
|
||||
def get_ktdm(self, wit = []):
|
||||
@@ -593,9 +595,9 @@ class Shitpost(commands.Cog):
|
||||
break
|
||||
if not zwarte_kaart:
|
||||
return None
|
||||
|
||||
|
||||
return zwarte_kaart.replace("___", "**{}**").format(*wit)
|
||||
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
async def ktdm(self, ctx, *args):
|
||||
'''Speel Kaarten Tegen De Mensheid! Genereer een kaart of geef zelf opties.
|
||||
@@ -644,23 +646,23 @@ class Shitpost(commands.Cog):
|
||||
"een systeem waar Lourens de boeken van online heeft gezet. FYI Mark speelt een dwerg, Guus is er in sessie twee pas bij (speelt ook een dwerg), Martijn iets met een accent en explosieven, Freek speelt Bob de Rooij en JP speelt het enige karakter wat het plot vooruit helpt godzijdank."
|
||||
]
|
||||
SPELLEN = [
|
||||
"DND", "Ars Magica",
|
||||
"een one-shot", "Kaarten tegen de Mensheid",
|
||||
"DND", "Ars Magica",
|
||||
"een one-shot", "Kaarten tegen de Mensheid",
|
||||
"Cyberpunk 2020", "Star Wars",
|
||||
"Blades in the Dark",
|
||||
"Blades in the Dark",
|
||||
"Expeditie Acquisitie", "Starfinder"
|
||||
]
|
||||
PLAATSEN = [
|
||||
"bij Mark thuis", "bij Freek thuis",
|
||||
"bij JP thuis", "bij Erik thuis",
|
||||
"bij Lourens thuis", "in de Vrouwensteeg",
|
||||
"bij Martijn thuis", "bij je moeder thuis",
|
||||
"bij Mark thuis", "bij Freek thuis",
|
||||
"bij JP thuis", "bij Erik thuis",
|
||||
"bij Lourens thuis", "in de Vrouwensteeg",
|
||||
"bij Martijn thuis", "bij je moeder thuis",
|
||||
"bij de Privé2000", "Vakantiepark Landal Kasteeldomein de Cauberg"
|
||||
]
|
||||
AANVANG = [
|
||||
"17:00.", "17:30.",
|
||||
"17:00.", "17:30.",
|
||||
"18:00.", "wanneer Lourens vrijgelaten wordt door de burgemeester.",
|
||||
"nadat de big in de bakfiets is langsgeweest.", "na Lourens' t-break.",
|
||||
"nadat de big in de bakfiets is langsgeweest.", "na Lourens' t-break.",
|
||||
"als Mark zijn frikadelbroodjes heeft.", "wanneer Martijn de datumprikker heeft ingevuld",
|
||||
"nadat iedereen tot 20:30 het uitgebreid over databases \"bij ons op het werk\" heeft gehad en de DM er een sarcastische opmerking over maakt.",
|
||||
"na een flinke portie slap gelul.", "nadat Mark tenminste 20 plaatjes in #tiger-girls heeft gepost.",
|
||||
@@ -668,15 +670,15 @@ class Shitpost(commands.Cog):
|
||||
"ongeveer een uur voordat JP's trein gaat."
|
||||
]
|
||||
PERSONEN = [
|
||||
"Mark", "Lourens", "JP",
|
||||
"Mark", "Lourens", "JP",
|
||||
"Freek", "Martijn", "Erik"
|
||||
]
|
||||
VIDYA = [
|
||||
"Factorio.", "Terraria.",
|
||||
"Factorio maar dan moet Martijn 5gr wiet inhaleren en Lourens 5mg ritalin slikken en dan kunnen JP en Mark fijn spelen.",
|
||||
"Terraria prepare to restart world edition.",
|
||||
"Terraria prepare to restart world edition.",
|
||||
"Crusader Kings III.", "Deep Rock Galactic.",
|
||||
"Dota 2.", "Minecraft.",
|
||||
"Dota 2.", "Minecraft.",
|
||||
"Minecraft met mods waardoor Guus niet mee kan doen maar maakt niet uit ik vond mijn huis toch leuker zonder TNT-traps.",
|
||||
"Minecraft met een of andere kutmodpack die Martijn gevonden heeft waardoor je de meeste troep niet zo maar kunt craften.",
|
||||
"Golf with y- oh het werkt niet op Linux? Oh jeetje oh nee, ja wat moeten we? Misschien kunnen we een ander spelletje - ja echt sorry ik weet het ook niet.",
|
||||
@@ -710,7 +712,7 @@ class Shitpost(commands.Cog):
|
||||
lekkerzaad += 1
|
||||
|
||||
random.seed(lekkerzaad)
|
||||
|
||||
|
||||
if Now.weekday() == 4:
|
||||
DAG = "vandaag "
|
||||
else:
|
||||
@@ -721,15 +723,15 @@ class Shitpost(commands.Cog):
|
||||
if KEUZEMOGELIJKHEDEN == 10:
|
||||
message = "We spelen " + DAG + random.choice(SASS)# + " Nee, we spelen eigenlijk " + random.choice(SPELLEN) + ", aanvang " + random.choice(AANVANG)
|
||||
elif KEUZEMOGELIJKHEDEN == 9:
|
||||
message = random.choice(PERSONEN) + " " + random.choice(GEBEURTENIS) + " " + random.choice(VIDYA)
|
||||
message = random.choice(PERSONEN) + " " + random.choice(GEBEURTENIS) + " " + random.choice(VIDYA)
|
||||
elif KEUZEMOGELIJKHEDEN == 8:
|
||||
message = "We gaan " + DAG + "poppetjes verven " + random.choice(PLAATSEN) + ", aanvang " + random.choice(AANVANG)
|
||||
elif KEUZEMOGELIJKHEDEN == 7:
|
||||
message = "We spelen " + DAG + random.choice(SPELLEN) + " " + random.choice(PLAATSEN) + ", aanvang " + random.choice(AANVANG) + random.choice(EXTRA)
|
||||
elif KEUZEMOGELIJKHEDEN == 6:
|
||||
elif KEUZEMOGELIJKHEDEN == 6:
|
||||
message = "We spelen " + DAG + random.choice(VIDYA) + " Ja, ik weet het, eigenlijk \"D&D\"-avond maar ja. Wees nou eerlijk heh. Aanvang " + random.choice(AANVANG)
|
||||
else:
|
||||
message = "We spelen " + DAG + random.choice(SPELLEN) + " " + random.choice(PLAATSEN) + ", aanvang " + random.choice(AANVANG)
|
||||
message = "We spelen " + DAG + random.choice(SPELLEN) + " " + random.choice(PLAATSEN) + ", aanvang " + random.choice(AANVANG)
|
||||
|
||||
return message
|
||||
|
||||
@@ -758,9 +760,9 @@ class Shitpost(commands.Cog):
|
||||
random.seed(datetime.now().timestamp())
|
||||
else:
|
||||
random.seed(topic.lower().replace(" ", ""))
|
||||
|
||||
|
||||
message = ""
|
||||
|
||||
|
||||
if topic == "":
|
||||
REVIEW_START = [
|
||||
"Ik vond 'm", "Ik vind 'm", "Ik vond het", "Ik vind het", "Als je het mij vraagt was ie", "Mijn mening:",
|
||||
@@ -772,7 +774,7 @@ class Shitpost(commands.Cog):
|
||||
"Ik ben geen expert, maar ik vond "+topic, topic+" was", topic+" is", topic+" is gewoon", "Mijn mening over "+topic+ ":",
|
||||
"Mijn review van "+topic+ ":"
|
||||
]
|
||||
|
||||
|
||||
SHORT_REVIEW = [
|
||||
"goed.", "goed!", "echt goed!", "prima.", "top.", "helemaal toppie!", "ruk.", "middelmatig.",
|
||||
"goed te doen.", "belabberd.", "uitstekend!", "uitmuntend.", "een beetje saai.", "supersick, yo.",
|
||||
@@ -783,10 +785,10 @@ class Shitpost(commands.Cog):
|
||||
":watermelon:", ":middle_finger:", ":poop:", ":banana:", ":eggplant:", ":red_car:", ":gem:",
|
||||
":heart:", ":flag_nl: ", ":cow:", ":dolphin:", ":four_leaf_clover:", ":basketball: ", ":thumbsup:"
|
||||
]
|
||||
|
||||
|
||||
message = random.choice(REVIEW_START) + " "
|
||||
message += random.choice(SHORT_REVIEW) + " "
|
||||
|
||||
|
||||
pickerScore = random.randint(1, 10)
|
||||
if pickerScore < 7:
|
||||
rating = random.randint(1, 5)
|
||||
@@ -800,8 +802,8 @@ class Shitpost(commands.Cog):
|
||||
emoj = random.choice(EMOJI)
|
||||
message += str(rating) + " " + emoj*rating + " out of " + str(maxRating) + "."
|
||||
|
||||
return message
|
||||
|
||||
return message
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
async def review(self, ctx, *args):
|
||||
"""Stroop heeft (bijna) overal een mening over. Vraag het hem!
|
||||
@@ -811,23 +813,66 @@ class Shitpost(commands.Cog):
|
||||
await ctx.channel.send(message)
|
||||
|
||||
def get_zaagmans(self):
|
||||
zaagman_url = "http://iszaagmansallangsgeweest.nl/"
|
||||
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
|
||||
now = datetime.now(self.TIME_ZONE)
|
||||
|
||||
@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):
|
||||
"""Is zaagmans al langsgeweest? Is de week al doormidden. Wie weet."""
|
||||
gezaagd = self.get_zaagmans()
|
||||
message = ctx.author.mention + ": "
|
||||
if gezaagd:
|
||||
message += gezaagd
|
||||
else:
|
||||
message += "De waarheid over zaagmans is niet te doorgronden."
|
||||
message = ctx.author.mention + ": " + self.get_zaagmans()
|
||||
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}".')
|
||||
@@ -29,6 +29,21 @@ intents.members = True
|
||||
|
||||
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'), description='Stroopwafel. Shitpost bot extraordinaire.', pm_help=True, intents=intents)
|
||||
|
||||
@bot.event
|
||||
async def on_command_error(ctx, error):
|
||||
if isinstance(error, commands.BadArgument):
|
||||
await ctx.send(f"{ctx.author.mention} Onheus gebruik van het commando. Lees de docs nog eens door:")
|
||||
await ctx.send_help(ctx.command)
|
||||
return
|
||||
if isinstance(error, commands.MissingRequiredArgument):
|
||||
await ctx.send(f"{ctx.author.mention} Volgens bij ben je nog iets vergeten toe te voegen aan dit commando. Lees de docs nog eens door:")
|
||||
await ctx.send_help(ctx.command)
|
||||
return
|
||||
if isinstance(error, commands.CommandNotFound):
|
||||
await ctx.send(f"{ctx.author.mention} Vermoedelijk bedoelde je iets anders. Typ !help voor alle opties.")
|
||||
return
|
||||
raise error
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
await add_cogs(bot)
|
||||
|
||||
Reference in new issue
Block a user