Merge pull request 'Update code om Python 3.11 te ondersteunen' (#22) from python311 into master
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
Reviewed-on: #22
This commit was merged in pull request #22.
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ name: default
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: test
|
- name: test
|
||||||
image: python:3.10
|
image: python:3.11
|
||||||
environment:
|
environment:
|
||||||
STROOP_DISCORD_TOKEN:
|
STROOP_DISCORD_TOKEN:
|
||||||
from_secret: STROOP_DISCORD_TOKEN
|
from_secret: STROOP_DISCORD_TOKEN
|
||||||
|
|||||||
+30
-38
@@ -1,4 +1,3 @@
|
|||||||
import asyncio
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -28,17 +27,16 @@ class Chatbot(commands.Cog):
|
|||||||
|
|
||||||
#Do stuff when a message comes in:
|
#Do stuff when a message comes in:
|
||||||
@self.bot.event
|
@self.bot.event
|
||||||
@asyncio.coroutine
|
async def on_message(message):
|
||||||
def on_message(message):
|
|
||||||
if message.author.bot:
|
if message.author.bot:
|
||||||
return #ignore your own messages, Stroop
|
return #ignore your own messages, Stroop
|
||||||
|
|
||||||
if message.content.strip() == "" or message.content.strip()[0] != '!': #don't respond to a command
|
if message.content.strip() == "" or message.content.strip()[0] != '!': #don't respond to a command
|
||||||
if message.content.lower() == "nihao":
|
if message.content.lower() == "nihao":
|
||||||
yield from message.channel.send("kankerlauw")
|
await message.channel.send("kankerlauw")
|
||||||
return
|
return
|
||||||
if message.content.lower() == "lol":
|
if message.content.lower() == "lol":
|
||||||
yield from message.channel.send("laffing aut laut")
|
await message.channel.send("laffing aut laut")
|
||||||
return
|
return
|
||||||
if self.bot.user.mentioned_in(message) and "@everyone" not in message.content:
|
if self.bot.user.mentioned_in(message) and "@everyone" not in message.content:
|
||||||
MENTIONED_RESPONSES = [
|
MENTIONED_RESPONSES = [
|
||||||
@@ -52,32 +50,32 @@ class Chatbot(commands.Cog):
|
|||||||
MENTIONED_RESPONSES.append("Wat mot je, " + random.choice(self.bot.get_cog("Shitpost").insult) + "?")
|
MENTIONED_RESPONSES.append("Wat mot je, " + random.choice(self.bot.get_cog("Shitpost").insult) + "?")
|
||||||
except:
|
except:
|
||||||
print("ERROR! - Could not import insults")
|
print("ERROR! - Could not import insults")
|
||||||
yield from message.channel.send(random.choice(MENTIONED_RESPONSES))
|
await message.channel.send(random.choice(MENTIONED_RESPONSES))
|
||||||
return
|
return
|
||||||
if re.match("^[0-9]+([,.]?[0-9]+)*?$", message.content.strip()) and random.randint(0,9) == 0:
|
if re.match("^[0-9]+([,.]?[0-9]+)*?$", message.content.strip()) and random.randint(0,9) == 0:
|
||||||
yield from message.channel.send("That's Numberwang!") # https://www.youtube.com/watch?v=0obMRztklqU
|
await message.channel.send("That's Numberwang!") # https://www.youtube.com/watch?v=0obMRztklqU
|
||||||
return
|
return
|
||||||
if "DMChannel" in type(message.channel).__name__: #respond to messages in PM channels
|
if "DMChannel" in type(message.channel).__name__: #respond to messages in PM channels
|
||||||
if (self.isAllowedToLearnFromPm(message)): #avoid spam-learning
|
if (self.isAllowedToLearnFromPm(message)): #avoid spam-learning
|
||||||
self.pmCount += 1
|
self.pmCount += 1
|
||||||
self.pmLast = datetime.now()
|
self.pmLast = datetime.now()
|
||||||
yield from self.learnFromMessagesInChannel(message.channel, 1)
|
await self.learnFromMessagesInChannel(message.channel, 1)
|
||||||
yield from self.respondToMessage(message)
|
await self.respondToMessage(message)
|
||||||
elif message.channel.id == self.bot.hdChannels["belangrijk"]: #don't abuse the "belangrijk" channel
|
elif message.channel.id == self.bot.hdChannels["belangrijk"]: #don't abuse the "belangrijk" channel
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
a = random.randint(0,999) # probablity
|
a = random.randint(0,999) # probablity
|
||||||
if a < 40:
|
if a < 40:
|
||||||
yield from self.learnFromMessagesInChannel(message.channel, 10)
|
await self.learnFromMessagesInChannel(message.channel, 10)
|
||||||
if "stroop" in message.content.lower():
|
if "stroop" in message.content.lower():
|
||||||
a = a / 20 # significantly increase the chance of responding if somebody talks about him.
|
a = a / 20 # significantly increase the chance of responding if somebody talks about him.
|
||||||
if message.channel.id == self.bot.hdChannels["shitpost"] and a < 40: #shitpost channel
|
if message.channel.id == self.bot.hdChannels["shitpost"] and a < 40: #shitpost channel
|
||||||
yield from self.respondToMessage(message)
|
await self.respondToMessage(message)
|
||||||
elif a < 10: #all other channels
|
elif a < 10: #all other channels
|
||||||
yield from self.respondToMessage(message)
|
await self.respondToMessage(message)
|
||||||
|
|
||||||
#process commands:
|
#process commands:
|
||||||
yield from self.bot.process_commands(message)
|
await self.bot.process_commands(message)
|
||||||
|
|
||||||
def __check(self, ctx):
|
def __check(self, ctx):
|
||||||
return True
|
return True
|
||||||
@@ -183,22 +181,20 @@ class Chatbot(commands.Cog):
|
|||||||
|
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=True)
|
@commands.command(pass_context=True, hidden=True)
|
||||||
@asyncio.coroutine
|
async def trainmarkovchat(self, ctx, channelId=409751773595566081, nrOfMessages=50):
|
||||||
def trainmarkovchat(self, ctx, channelId=409751773595566081, nrOfMessages=50):
|
|
||||||
"""Train that chain, jermaine
|
"""Train that chain, jermaine
|
||||||
param channelId: use this channel to train
|
param channelId: use this channel to train
|
||||||
param nrOfMessages: use the x most recent messages
|
param nrOfMessages: use the x most recent messages
|
||||||
"""
|
"""
|
||||||
|
|
||||||
channel=self.bot.get_channel(channelId)
|
channel=self.bot.get_channel(channelId)
|
||||||
yield from self.learnFromMessagesInChannel(channel, nrOfMessages)
|
await self.learnFromMessagesInChannel(channel, nrOfMessages)
|
||||||
|
|
||||||
yield from ctx.channel.send("Ik heb weer wat nieuwe woordjes geleerd. :slight_smile:")
|
await ctx.channel.send("Ik heb weer wat nieuwe woordjes geleerd. :slight_smile:")
|
||||||
|
|
||||||
|
|
||||||
#Learns from an x number of messages from a certain channel
|
#Learns from an x number of messages from a certain channel
|
||||||
@asyncio.coroutine
|
async def learnFromMessagesInChannel(self, channel, nrOfMessages):
|
||||||
def learnFromMessagesInChannel(self, channel, nrOfMessages):
|
|
||||||
|
|
||||||
#Open current chain:
|
#Open current chain:
|
||||||
wordDict = np.load('markov_dict.npy', allow_pickle=True).item()
|
wordDict = np.load('markov_dict.npy', allow_pickle=True).item()
|
||||||
@@ -207,7 +203,7 @@ class Chatbot(commands.Cog):
|
|||||||
messageIterator = channel.history(limit=nrOfMessages, before=None, after=None, oldest_first=False, around=None)
|
messageIterator = channel.history(limit=nrOfMessages, before=None, after=None, oldest_first=False, around=None)
|
||||||
allMessages = []
|
allMessages = []
|
||||||
for i in range(nrOfMessages):
|
for i in range(nrOfMessages):
|
||||||
msg = yield from anext(messageIterator)
|
msg = await anext(messageIterator)
|
||||||
allMessages.append(msg)
|
allMessages.append(msg)
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
@@ -248,18 +244,17 @@ class Chatbot(commands.Cog):
|
|||||||
|
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def reageer(self, ctx):
|
||||||
def reageer(self, ctx):
|
|
||||||
"""Laat Stroop ergens op reageren.
|
"""Laat Stroop ergens op reageren.
|
||||||
Stroop leert van onze gesprekken. Hij kan zich nu voordoen als een van ons. Soort van.
|
Stroop leert van onze gesprekken. Hij kan zich nu voordoen als een van ons. Soort van.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#Get previous message to respond to
|
#Get previous message to respond to
|
||||||
messageIterator = ctx.channel.history(limit=3, before=None, after=None, oldest_first=False, around=None)
|
messageIterator = ctx.channel.history(limit=3, before=None, after=None, oldest_first=False, around=None)
|
||||||
messageToRespondTo = yield from anext(messageIterator) #this will be the !reageer command. skip
|
messageToRespondTo = await anext(messageIterator) #this will be the !reageer command. skip
|
||||||
messageToRespondTo = yield from anext(messageIterator)
|
messageToRespondTo = await anext(messageIterator)
|
||||||
if messageToRespondTo.content.strip()[0] == '!' or messageToRespondTo.author.bot: #another chance
|
if messageToRespondTo.content.strip()[0] == '!' or messageToRespondTo.author.bot: #another chance
|
||||||
messageToRespondTo = yield from anext(messageIterator) #but it's not a huge problem if he responds to himself
|
messageToRespondTo = await anext(messageIterator) #but it's not a huge problem if he responds to himself
|
||||||
if messageToRespondTo.content.strip()[0] == '!':
|
if messageToRespondTo.content.strip()[0] == '!':
|
||||||
wordsToRespondTo = []
|
wordsToRespondTo = []
|
||||||
else:
|
else:
|
||||||
@@ -268,12 +263,12 @@ class Chatbot(commands.Cog):
|
|||||||
|
|
||||||
#Delete command
|
#Delete command
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
response = self.getResponseForMessage(wordsToRespondTo)
|
response = self.getResponseForMessage(wordsToRespondTo)
|
||||||
yield from ctx.channel.send(response)
|
await ctx.channel.send(response)
|
||||||
|
|
||||||
# Calculate probabilities and pick a next word from a word pair dict:
|
# Calculate probabilities and pick a next word from a word pair dict:
|
||||||
# https://stackoverflow.com/questions/835092/python-dictionary-are-keys-and-values-always-the-same-order
|
# https://stackoverflow.com/questions/835092/python-dictionary-are-keys-and-values-always-the-same-order
|
||||||
@@ -285,12 +280,11 @@ class Chatbot(commands.Cog):
|
|||||||
|
|
||||||
#Respond to a message.
|
#Respond to a message.
|
||||||
#Assumes the message isn't a command
|
#Assumes the message isn't a command
|
||||||
@asyncio.coroutine
|
async def respondToMessage(self, message):
|
||||||
def respondToMessage(self, message):
|
|
||||||
wordsToRespondTo = message.content.strip().split()
|
wordsToRespondTo = message.content.strip().split()
|
||||||
|
|
||||||
response = self.getResponseForMessage(wordsToRespondTo)
|
response = self.getResponseForMessage(wordsToRespondTo)
|
||||||
yield from message.channel.send(response)
|
await message.channel.send(response)
|
||||||
|
|
||||||
#Gets a response
|
#Gets a response
|
||||||
def getResponseForMessage(self, wordsToRespondTo):
|
def getResponseForMessage(self, wordsToRespondTo):
|
||||||
@@ -351,7 +345,7 @@ class Chatbot(commands.Cog):
|
|||||||
chain[n] = "@jemoeder"
|
chain[n] = "@jemoeder"
|
||||||
|
|
||||||
#print(' '.join(chain))
|
#print(' '.join(chain))
|
||||||
#yield from ctx.channel.send(' '.join(chain))
|
#await ctx.channel.send(' '.join(chain))
|
||||||
return ' '.join(chain)
|
return ' '.join(chain)
|
||||||
|
|
||||||
|
|
||||||
@@ -424,22 +418,20 @@ class Chatbot(commands.Cog):
|
|||||||
return ' '.join(chain)
|
return ' '.join(chain)
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def haiku(self, ctx):
|
||||||
def haiku(self, ctx):
|
|
||||||
"""Stroop is een poëet. Laat hem een Haiku maken.
|
"""Stroop is een poëet. Laat hem een Haiku maken.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
response = self.getHaiku()
|
response = self.getHaiku()
|
||||||
yield from ctx.channel.send(response)
|
await ctx.channel.send(response)
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def uitspraak(self, ctx, numPosts=1):
|
||||||
def uitspraak(self, ctx, numPosts=1):
|
|
||||||
"""Random uitspraak uit de hall of fame.
|
"""Random uitspraak uit de hall of fame.
|
||||||
Optioneel kan je een nummer meegeven voor meerdere uitspraken
|
Optioneel kan je een nummer meegeven voor meerdere uitspraken
|
||||||
0 voor alle uitspraken."""
|
0 voor alle uitspraken."""
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
@@ -451,6 +443,6 @@ class Chatbot(commands.Cog):
|
|||||||
numPosts = len(uitspraken)
|
numPosts = len(uitspraken)
|
||||||
for i in range(numPosts):
|
for i in range(numPosts):
|
||||||
message += uitspraken[i]
|
message += uitspraken[i]
|
||||||
yield from ctx.channel.send(message)
|
await ctx.channel.send(message)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM python:3.10
|
FROM python:3.11
|
||||||
|
|
||||||
WORKDIR /opt/stroopwafel
|
WORKDIR /opt/stroopwafel
|
||||||
|
|
||||||
|
|||||||
+12
-17
@@ -1,4 +1,3 @@
|
|||||||
import asyncio
|
|
||||||
import discord
|
import discord
|
||||||
import os
|
import os
|
||||||
import praw
|
import praw
|
||||||
@@ -30,18 +29,17 @@ class General(commands.Cog):
|
|||||||
return embed
|
return embed
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@asyncio.coroutine
|
async def huge(self, ctx, *, arg):
|
||||||
def huge(self, ctx, *, arg):
|
|
||||||
"""YUGE. Geeft een grote versie van de gegeven emoji terug. Werkt alleen voor custom emoji.
|
"""YUGE. Geeft een grote versie van de gegeven emoji terug. Werkt alleen voor custom emoji.
|
||||||
Bijvoorbeeld:
|
Bijvoorbeeld:
|
||||||
!huge :ancilla:
|
!huge :ancilla:
|
||||||
"""
|
"""
|
||||||
em = self.get_emoji_embed(arg)
|
em = self.get_emoji_embed(arg)
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
yield from 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.r.subreddit('aww+catloaf+tuckedinkitties+babyelephantgifs+babybigcatgifs+blep+holdmynip+gingerkitty+cathighfive+catsstandingup+catsareassholes+eyebleach')
|
||||||
@@ -49,15 +47,14 @@ class General(commands.Cog):
|
|||||||
return random.choice(listing)
|
return random.choice(listing)
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
async def aww(self, ctx):
|
||||||
def aww(self, ctx):
|
|
||||||
""" iets schattigs... """
|
""" iets schattigs... """
|
||||||
post = self.get_aww_post()
|
post = self.get_aww_post()
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
yield from 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.r.subreddit('kopieerpasta')
|
||||||
@@ -71,8 +68,7 @@ class General(commands.Cog):
|
|||||||
return post
|
return post
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
async def kopieerpasta(self, ctx):
|
||||||
def kopieerpasta(self, ctx):
|
|
||||||
"""Een willekeurige shitpost"""
|
"""Een willekeurige shitpost"""
|
||||||
post = self.get_kopieerpasta()
|
post = self.get_kopieerpasta()
|
||||||
print(post.url)
|
print(post.url)
|
||||||
@@ -83,23 +79,22 @@ class General(commands.Cog):
|
|||||||
print(post.url)
|
print(post.url)
|
||||||
a += 1
|
a += 1
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
|
|
||||||
if len(post.selftext + post.title) < 1990:
|
if len(post.selftext + post.title) < 1990:
|
||||||
yield from ctx.channel.send('**'+post.title+'**```'+post.selftext+'```')
|
await ctx.channel.send('**'+post.title+'**```'+post.selftext+'```')
|
||||||
else:
|
else:
|
||||||
yield from ctx.channel.send("Geen kopieerpasta voor jou vandaag.")
|
await ctx.channel.send("Geen kopieerpasta voor jou vandaag.")
|
||||||
|
|
||||||
def get_playlist_json(self):
|
def get_playlist_json(self):
|
||||||
return requests.get(self.muzak_url + '/stroopwafel')
|
return requests.get(self.muzak_url + '/stroopwafel')
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
async def playlist(self, ctx):
|
||||||
def playlist(self, ctx):
|
|
||||||
"""HDcon2021 playlist"""
|
"""HDcon2021 playlist"""
|
||||||
data = json.loads(self.get_playlist_json().content)
|
data = json.loads(self.get_playlist_json().content)
|
||||||
msg = 'Stemmen en nomineren kan hier: {}\n'.format(self.muzak_url)
|
msg = 'Stemmen en nomineren kan hier: {}\n'.format(self.muzak_url)
|
||||||
msg += '*Er zijn al {} nummers genomineerd*\n'.format(data['stemCount'])
|
msg += '*Er zijn al {} nummers genomineerd*\n'.format(data['stemCount'])
|
||||||
yield from ctx.channel.send(msg)
|
await ctx.channel.send(msg)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import asyncio
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
@@ -25,8 +24,7 @@ class Points(commands.Cog):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def geefpunten(self, ctx, user, points: int):
|
||||||
def geefpunten(self, ctx, user, points: int):
|
|
||||||
"""Wees eens lief. Geef iemand wat punten.
|
"""Wees eens lief. Geef iemand wat punten.
|
||||||
Bijvoorbeeld:
|
Bijvoorbeeld:
|
||||||
!geefpunten @ikbenjp 42
|
!geefpunten @ikbenjp 42
|
||||||
@@ -37,29 +35,29 @@ class Points(commands.Cog):
|
|||||||
self.reloadPointsCount()
|
self.reloadPointsCount()
|
||||||
|
|
||||||
if points == 0:
|
if points == 0:
|
||||||
yield from ctx.channel.send("0 punten? Gul hoor.")
|
await ctx.channel.send("0 punten? Gul hoor.")
|
||||||
return
|
return
|
||||||
if points < 0:
|
if points < 0:
|
||||||
yield from self.sendErrorDm(ctx, "Daar hebben we de !neempunten functie voor. Voor meer info typ: ```!help neempunten```")
|
await self.sendErrorDm(ctx, "Daar hebben we de !neempunten functie voor. Voor meer info typ: ```!help neempunten```")
|
||||||
return
|
return
|
||||||
|
|
||||||
if user[0:2] != "<@":
|
if user[0:2] != "<@":
|
||||||
yield from self.sendErrorDm(ctx, "Je moet iemand taggen om punten te geven. :)")
|
await self.sendErrorDm(ctx, "Je moet iemand taggen om punten te geven. :)")
|
||||||
#TODO ook userId oid toestaan?
|
#TODO ook userId oid toestaan?
|
||||||
return
|
return
|
||||||
|
|
||||||
userObj = ctx.message.mentions[0]
|
userObj = ctx.message.mentions[0]
|
||||||
|
|
||||||
if userObj.id == ctx.author.id:
|
if userObj.id == ctx.author.id:
|
||||||
yield from ctx.channel.send("Nee. Je mag niet jezelf punten geven.")
|
await ctx.channel.send("Nee. Je mag niet jezelf punten geven.")
|
||||||
time.sleep(0.6)
|
time.sleep(0.6)
|
||||||
yield from ctx.channel.send("Gekkie.")
|
await ctx.channel.send("Gekkie.")
|
||||||
return
|
return
|
||||||
if not self.isUserOnList(userObj):
|
if not self.isUserOnList(userObj):
|
||||||
yield from ctx.channel.send("Nee. Die krijgt geen punten.")
|
await ctx.channel.send("Nee. Die krijgt geen punten.")
|
||||||
return
|
return
|
||||||
if self.getUserBalance(ctx.author) < points:
|
if self.getUserBalance(ctx.author) < points:
|
||||||
yield from ctx.channel.send("Daar heb jij niet genoeg puntjes voor. :bell:")
|
await ctx.channel.send("Daar heb jij niet genoeg puntjes voor. :bell:")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Execute the transaction:
|
# Execute the transaction:
|
||||||
@@ -68,7 +66,7 @@ class Points(commands.Cog):
|
|||||||
self.savePointsCount()
|
self.savePointsCount()
|
||||||
|
|
||||||
message = self.getMessageForAwardingPoints(ctx.author.name, userObj.name, points)
|
message = self.getMessageForAwardingPoints(ctx.author.name, userObj.name, points)
|
||||||
yield from ctx.channel.send(message)
|
await ctx.channel.send(message)
|
||||||
|
|
||||||
def execute_geefpunten(self, giverId, recieverId, points):
|
def execute_geefpunten(self, giverId, recieverId, points):
|
||||||
# First, try to give away (at most 10) bankpoints
|
# First, try to give away (at most 10) bankpoints
|
||||||
@@ -86,8 +84,7 @@ class Points(commands.Cog):
|
|||||||
|
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def neempunten(self, ctx, user, points: int):
|
||||||
def neempunten(self, ctx, user, points: int):
|
|
||||||
"""Tijd om iemand the shamen. Haal wat punten weg.
|
"""Tijd om iemand the shamen. Haal wat punten weg.
|
||||||
Bijvoorbeeld:
|
Bijvoorbeeld:
|
||||||
!neempunten @mark 5
|
!neempunten @mark 5
|
||||||
@@ -98,27 +95,27 @@ class Points(commands.Cog):
|
|||||||
self.reloadPointsCount()
|
self.reloadPointsCount()
|
||||||
|
|
||||||
if points < 1:
|
if points < 1:
|
||||||
yield from ctx.channel.send("Volgens mij snap je het niet.")
|
await ctx.channel.send("Volgens mij snap je het niet.")
|
||||||
return
|
return
|
||||||
if points > 10:
|
if points > 10:
|
||||||
yield from self.sendErrorDm(ctx, "Je mag niet meer dan 10 punten afnemen.")
|
await self.sendErrorDm(ctx, "Je mag niet meer dan 10 punten afnemen.")
|
||||||
return
|
return
|
||||||
remainingToTakeAway = self.getUsersRemainingPointsToTakeToday(ctx.author.id)
|
remainingToTakeAway = self.getUsersRemainingPointsToTakeToday(ctx.author.id)
|
||||||
if points > remainingToTakeAway: # The limit per day is 10
|
if points > remainingToTakeAway: # The limit per day is 10
|
||||||
yield from self.sendErrorDm(ctx, "Je mag vandaag nog maar " + str(remainingToTakeAway) + " punten wegnemen.")
|
await self.sendErrorDm(ctx, "Je mag vandaag nog maar " + str(remainingToTakeAway) + " punten wegnemen.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if user[0:2] != "<@":
|
if user[0:2] != "<@":
|
||||||
yield from self.sendErrorDm(ctx, "Je moet iemand taggen. :)")
|
await self.sendErrorDm(ctx, "Je moet iemand taggen. :)")
|
||||||
return
|
return
|
||||||
|
|
||||||
userObj = ctx.message.mentions[0]
|
userObj = ctx.message.mentions[0]
|
||||||
|
|
||||||
if not self.isUserOnList(userObj):
|
if not self.isUserOnList(userObj):
|
||||||
yield from ctx.channel.send("Nee.")
|
await ctx.channel.send("Nee.")
|
||||||
return
|
return
|
||||||
if self.getUserBalance(userObj) < points:
|
if self.getUserBalance(userObj) < points:
|
||||||
yield from ctx.channel.send(userObj.name + " mag niet rood staan.")
|
await ctx.channel.send(userObj.name + " mag niet rood staan.")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Execute the transaction:
|
# Execute the transaction:
|
||||||
@@ -127,7 +124,7 @@ class Points(commands.Cog):
|
|||||||
self.savePointsCount()
|
self.savePointsCount()
|
||||||
|
|
||||||
message = self.getMessageForTakingPoints(userObj.name, ctx.author.name, points)
|
message = self.getMessageForTakingPoints(userObj.name, ctx.author.name, points)
|
||||||
yield from ctx.channel.send(message)
|
await ctx.channel.send(message)
|
||||||
|
|
||||||
def execute_neempunten(self, takerId, victimId, points):
|
def execute_neempunten(self, takerId, victimId, points):
|
||||||
self.increaseUsersPointTakenOnDate(takerId, points)
|
self.increaseUsersPointTakenOnDate(takerId, points)
|
||||||
@@ -135,8 +132,7 @@ class Points(commands.Cog):
|
|||||||
|
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def puntentelling(self, ctx):
|
||||||
def puntentelling(self, ctx):
|
|
||||||
"""Hoeveel punten heeft iedereen?
|
"""Hoeveel punten heeft iedereen?
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -148,18 +144,17 @@ class Points(commands.Cog):
|
|||||||
if user[0] != self.BANK_ID:
|
if user[0] != self.BANK_ID:
|
||||||
message += str(user[1]["points"]).rjust(4) + " " + user[1]["name"] + "\n"
|
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"] + "```"
|
message += str(self.pointsCount[self.BANK_ID]["points"]).rjust(4) + " " + self.pointsCount[self.BANK_ID]["name"] + "```"
|
||||||
yield from ctx.channel.send(message)
|
await ctx.channel.send(message)
|
||||||
|
|
||||||
|
|
||||||
# No public shaming. Send somebody a direct correction message.
|
# No public shaming. Send somebody a direct correction message.
|
||||||
@asyncio.coroutine
|
async def sendErrorDm(self, ctx, message):
|
||||||
def sendErrorDm(self, ctx, message):
|
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.author.send(message)
|
await ctx.message.author.send(message)
|
||||||
except:
|
except:
|
||||||
print("No permission to send DM")
|
print("No permission to send DM")
|
||||||
|
|
||||||
|
|||||||
+62
-83
@@ -1,4 +1,3 @@
|
|||||||
import asyncio
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from urllib import request
|
from urllib import request
|
||||||
@@ -43,8 +42,7 @@ class Shitpost(commands.Cog):
|
|||||||
warnings.simplefilter("ignore")
|
warnings.simplefilter("ignore")
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def ishetalhdcon(self, ctx):
|
||||||
def ishetalhdcon(self, ctx):
|
|
||||||
"""Hoe lang nog tot Hoestende Draken Con 2022?
|
"""Hoe lang nog tot Hoestende Draken Con 2022?
|
||||||
Gebruik: !ishetalhdcon
|
Gebruik: !ishetalhdcon
|
||||||
"""
|
"""
|
||||||
@@ -61,7 +59,7 @@ class Shitpost(commands.Cog):
|
|||||||
Message = "HD Con 2022 is vandaag alweer afgelopen... F"
|
Message = "HD Con 2022 is vandaag alweer afgelopen... F"
|
||||||
|
|
||||||
if Distance.days < 0:
|
if Distance.days < 0:
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
await ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
||||||
return
|
return
|
||||||
|
|
||||||
NachtjesSlapen = Distance.days + 1
|
NachtjesSlapen = Distance.days + 1
|
||||||
@@ -90,23 +88,23 @@ class Shitpost(commands.Cog):
|
|||||||
return #fuck it.
|
return #fuck it.
|
||||||
if eventsMinutesAgoSameAuthor > 0:
|
if eventsMinutesAgoSameAuthor > 0:
|
||||||
if eventsMinutesAgoSameAuthor > 2:
|
if eventsMinutesAgoSameAuthor > 2:
|
||||||
yield from ctx.channel.send("...")
|
await ctx.channel.send("...")
|
||||||
return
|
return
|
||||||
yield from 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
|
return
|
||||||
#Hoe vaker er wordt gevraagd, hoe ongeduldiger de antwoorden:
|
#Hoe vaker er wordt gevraagd, hoe ongeduldiger de antwoorden:
|
||||||
if not "DMChannel" in type(ctx.channel).__name__: #ignore personal chats
|
if not "DMChannel" in type(ctx.channel).__name__: #ignore personal chats
|
||||||
impatientFactor = 10 + eventsMinutesAgo*25 + eventsLastDays*10;
|
impatientFactor = 10 + eventsMinutesAgo*25 + eventsLastDays*10;
|
||||||
impatientFactor *= random.random()
|
impatientFactor *= random.random()
|
||||||
if impatientFactor > 100:
|
if impatientFactor > 100:
|
||||||
yield from ctx.channel.send("Nee!")
|
await ctx.channel.send("Nee!")
|
||||||
return
|
return
|
||||||
elif impatientFactor > 15 and eventsMinutesAgo > 0:
|
elif impatientFactor > 15 and eventsMinutesAgo > 0:
|
||||||
Message = "Dat hebben jullie net gevraagd."
|
Message = "Dat hebben jullie net gevraagd."
|
||||||
elif impatientFactor > 9:
|
elif impatientFactor > 9:
|
||||||
Message = "Nee."
|
Message = "Nee."
|
||||||
|
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
await ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
||||||
|
|
||||||
def zalgofy(self, sentence, factor = 4):
|
def zalgofy(self, sentence, factor = 4):
|
||||||
random.seed(datetime.now().timestamp())
|
random.seed(datetime.now().timestamp())
|
||||||
@@ -119,8 +117,7 @@ class Shitpost(commands.Cog):
|
|||||||
return message
|
return message
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def zalgo(self, ctx, *, arg):
|
||||||
def zalgo(self, ctx, *, arg):
|
|
||||||
"""z̴̬̘͇̗͇̦̤̩̜͜ą̷̟̯̪̩̣̭̭͇̹l̴̗͓̟̠̤̳̗͉̠ͅg̵̜͎̪̞̫͎͈͉͉͍o̵̧̧͇̱̱̜̮͉͉̳ ̴̨̡͖̘̪̭̖͖̘̝h̸̭̰̫̲̺̹̻̜͕ͅe̴̢̘̪̱̱̩̠̣̘̱ ̴̡̢̲̞̙̝̮̻̻͇c̶̡̢̺͙̮̗̲̹̱̱o̷̢̡̺̘͈͎̫̬͔̤m̷͕͍͍̥͖̻̲̞̝ͅe̷̱̟͕̥͕̞̜̫̳̙s̷̨͍̼̝̙̩̥̰̠ͅ
|
"""z̴̬̘͇̗͇̦̤̩̜͜ą̷̟̯̪̩̣̭̭͇̹l̴̗͓̟̠̤̳̗͉̠ͅg̵̜͎̪̞̫͎͈͉͉͍o̵̧̧͇̱̱̜̮͉͉̳ ̴̨̡͖̘̪̭̖͖̘̝h̸̭̰̫̲̺̹̻̜͕ͅe̴̢̘̪̱̱̩̠̣̘̱ ̴̡̢̲̞̙̝̮̻̻͇c̶̡̢̺͙̮̗̲̹̱̱o̷̢̡̺̘͈͎̫̬͔̤m̷͕͍͍̥͖̻̲̞̝ͅe̷̱̟͕̥͕̞̜̫̳̙s̷̨͍̼̝̙̩̥̰̠ͅ
|
||||||
h̷̦̰̣̗̭͕̩͓͈̠i̶̗̰̹̤̖͙̰̹͙̹j̸̧̜̬̬̜̹͔̰̫͜ ̶̧͉͔̠̻͈̜̳̥̭k̸̯̳̠̼̙̗̘̳͜ͅǫ̵̝̱̩͎̫͈̣̪̦m̶̺̙̟̫͔͈̭̖̱ͅt̶̜̠̟͙̞̠̗̗̥ͅ ̸̢̹̜͉͙̩̬̖ͅͅh̷̯̮̘̭͈̜̺͎̳̯i̴̩̯̼̱͇̟̫̻̘̖j̵̪̤̦͖̮̜̦̼̺̮ ̶̧͇̭̞̮̩̼͚̮ͅḵ̴̢̨̢͉͉͖̹̬̺o̵̢̪̥̻͙͕̫̥̗͜m̶̧̡͔̠̺͖̝̳̪ͅt̷̢̮̭̜̥̠̼̫͍̯
|
h̷̦̰̣̗̭͕̩͓͈̠i̶̗̰̹̤̖͙̰̹͙̹j̸̧̜̬̬̜̹͔̰̫͜ ̶̧͉͔̠̻͈̜̳̥̭k̸̯̳̠̼̙̗̘̳͜ͅǫ̵̝̱̩͎̫͈̣̪̦m̶̺̙̟̫͔͈̭̖̱ͅt̶̜̠̟͙̞̠̗̗̥ͅ ̸̢̹̜͉͙̩̬̖ͅͅh̷̯̮̘̭͈̜̺͎̳̯i̴̩̯̼̱͇̟̫̻̘̖j̵̪̤̦͖̮̜̦̼̺̮ ̶̧͇̭̞̮̩̼͚̮ͅḵ̴̢̨̢͉͉͖̹̬̺o̵̢̪̥̻͙͕̫̥̗͜m̶̧̡͔̠̺͖̝̳̪ͅt̷̢̮̭̜̥̠̼̫͍̯
|
||||||
d̷̢̪͍͓̭̣̼̠͎̠e̴̡̢̩̱͙̻̥̯͎͜ ̵̲̪͖̖͖͍͈͎̮̼ļ̴̯̗̝̦͍͍͖̰͜i̶̡̘̟̳̖͙͕͔̺͜ȩ̸̤͎̣͖͔̭͔̫̯v̷͔̺͖̖̞̙̘̖̠͓e̶̲͍̮̳͎̗̳̞̹͔ ̸̡̬̫͎͎̝͍̤̯ͅg̴̨̞̻͙̠̰͖͖̝ͅǫ̴̘̥͇̙̖͈͍̹̥e̵̥͇̫̱̬̝̥̲̞̜d̷͈͙̝͍͔̘͕̼̜̦e̴̡̯̦͉͙̪̭͕̻̝
|
d̷̢̪͍͓̭̣̼̠͎̠e̴̡̢̩̱͙̻̥̯͎͜ ̵̲̪͖̖͖͍͈͎̮̼ļ̴̯̗̝̦͍͍͖̰͜i̶̡̘̟̳̖͙͕͔̺͜ȩ̸̤͎̣͖͔̭͔̫̯v̷͔̺͖̖̞̙̘̖̠͓e̶̲͍̮̳͎̗̳̞̹͔ ̸̡̬̫͎͎̝͍̤̯ͅg̴̨̞̻͙̠̰͖͖̝ͅǫ̴̘̥͇̙̖͈͍̹̥e̵̥͇̫̱̬̝̥̲̞̜d̷͈͙̝͍͔̘͕̼̜̦e̴̡̯̦͉͙̪̭͕̻̝
|
||||||
@@ -130,10 +127,10 @@ class Shitpost(commands.Cog):
|
|||||||
"""
|
"""
|
||||||
message = self.zalgofy(arg)
|
message = self.zalgofy(arg)
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
yield from ctx.channel.send(str(message))
|
await ctx.channel.send(str(message))
|
||||||
|
|
||||||
def get_corona_message(self):
|
def get_corona_message(self):
|
||||||
response = requests.get('https://covid.ourworldindata.org/data/latest/owid-covid-latest.json')
|
response = requests.get('https://covid.ourworldindata.org/data/latest/owid-covid-latest.json')
|
||||||
@@ -151,18 +148,16 @@ class Shitpost(commands.Cog):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def corona(self, ctx):
|
||||||
def corona(self, ctx):
|
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
message = self.get_corona_message()
|
message = self.get_corona_message()
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' ' + str(message))
|
await ctx.channel.send(ctx.author.mention + ' ' + str(message))
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def viertwintig(self, ctx):
|
||||||
def viertwintig(self, ctx):
|
|
||||||
"""Hoe lang nog tot 420?
|
"""Hoe lang nog tot 420?
|
||||||
Gebruik: !viertwintig
|
Gebruik: !viertwintig
|
||||||
"""
|
"""
|
||||||
@@ -188,11 +183,10 @@ class Shitpost(commands.Cog):
|
|||||||
seconds = secondsLeft - minutes * 60
|
seconds = secondsLeft - minutes * 60
|
||||||
Message += "Nog " + str(days) + " dagen, " + str(hours) + " uur, " + str(minutes) + " minuten en " + str(seconds) + " seconden tot 420!!"
|
Message += "Nog " + str(days) + " dagen, " + str(hours) + " uur, " + str(minutes) + " minuten en " + str(seconds) + " seconden tot 420!!"
|
||||||
|
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
await ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def iselderscrolls6aluit(self, ctx):
|
||||||
def iselderscrolls6aluit(self, ctx):
|
|
||||||
"""Hoe lang nog tot Elder Scrolls 6? 11-11-11? 20-20-20?
|
"""Hoe lang nog tot Elder Scrolls 6? 11-11-11? 20-20-20?
|
||||||
Gebruik: !iselderscrolls6aluit
|
Gebruik: !iselderscrolls6aluit
|
||||||
"""
|
"""
|
||||||
@@ -203,15 +197,14 @@ class Shitpost(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
Message = "Nee. :frowning2: Nog even geduld..."
|
Message = "Nee. :frowning2: Nog even geduld..."
|
||||||
|
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
await ctx.channel.send(ctx.author.mention + ' ' + str(Message))
|
||||||
|
|
||||||
def get_giet_het_oan(self):
|
def get_giet_het_oan(self):
|
||||||
# Alsof we ooit nog een elfstedentocht gaan krijgen.
|
# Alsof we ooit nog een elfstedentocht gaan krijgen.
|
||||||
return "nee"
|
return "nee"
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def giethetaloan(self, ctx):
|
||||||
def giethetaloan(self, ctx):
|
|
||||||
"""Giet het al oan?
|
"""Giet het al oan?
|
||||||
Ja of Nee.. kom op nou.
|
Ja of Nee.. kom op nou.
|
||||||
"""
|
"""
|
||||||
@@ -225,7 +218,7 @@ class Shitpost(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
if 'nee' in answer:
|
if 'nee' in answer:
|
||||||
reactie += 'Nee helaas..'
|
reactie += 'Nee helaas..'
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' ' + reactie)
|
await ctx.channel.send(ctx.author.mention + ' ' + reactie)
|
||||||
|
|
||||||
def get_inspiration(self):
|
def get_inspiration(self):
|
||||||
inspiration = requests.get(url='http://inspirobot.me/api?generate=true')
|
inspiration = requests.get(url='http://inspirobot.me/api?generate=true')
|
||||||
@@ -235,8 +228,7 @@ class Shitpost(commands.Cog):
|
|||||||
|
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
async def inspire(self, ctx):
|
||||||
def inspire(self, ctx):
|
|
||||||
"""Laat je inspireren
|
"""Laat je inspireren
|
||||||
Bijvoorbeeld:
|
Bijvoorbeeld:
|
||||||
!inspire
|
!inspire
|
||||||
@@ -246,12 +238,12 @@ class Shitpost(commands.Cog):
|
|||||||
em = discord.Embed(title='Uw wijze woorden:', type='photo')
|
em = discord.Embed(title='Uw wijze woorden:', type='photo')
|
||||||
em.set_image(url=inspo)
|
em.set_image(url=inspo)
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
await ctx.channel.send(ctx.author.mention, embed=em)
|
||||||
else:
|
else:
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' helaas, geen quote gevonden.')
|
await ctx.channel.send(ctx.author.mention + ' helaas, geen quote gevonden.')
|
||||||
|
|
||||||
def get_imgflip_embed(self, template: str, boven: str, onder: str, extra_options: dict = None):
|
def get_imgflip_embed(self, template: str, boven: str, onder: str, extra_options: dict = None):
|
||||||
params = dict(
|
params = dict(
|
||||||
@@ -273,49 +265,46 @@ class Shitpost(commands.Cog):
|
|||||||
|
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=True)
|
@commands.command(pass_context=True, hidden=True)
|
||||||
@asyncio.coroutine
|
async def tering(self, ctx, boven: str, onder: str):
|
||||||
def tering(self, ctx, boven: str, onder: str):
|
|
||||||
"""Vanavond gaan we helemaal naar de tering
|
"""Vanavond gaan we helemaal naar de tering
|
||||||
Bijvoorbeeld:
|
Bijvoorbeeld:
|
||||||
!tering \"Vanavond\" \"gaan we helemaal naar de tering\"
|
!tering \"Vanavond\" \"gaan we helemaal naar de tering\"
|
||||||
"""
|
"""
|
||||||
em = self.get_imgflip_embed(self.imgflips['tering'], boven, onder)
|
em = self.get_imgflip_embed(self.imgflips['tering'], boven, onder)
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
if em:
|
if em:
|
||||||
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
await ctx.channel.send(ctx.author.mention, embed=em)
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=True)
|
@commands.command(pass_context=True, hidden=True)
|
||||||
@asyncio.coroutine
|
async def mark(self, ctx, boven: str, onder: str):
|
||||||
def mark(self, ctx, boven: str, onder: str):
|
|
||||||
"""Maakt een mark meem.
|
"""Maakt een mark meem.
|
||||||
Bijvoorbeeld:
|
Bijvoorbeeld:
|
||||||
!mark \"je moeder\" \"is een hoer\"
|
!mark \"je moeder\" \"is een hoer\"
|
||||||
"""
|
"""
|
||||||
em = self.get_imgflip_embed(self.imgflips['mark'], boven, onder)
|
em = self.get_imgflip_embed(self.imgflips['mark'], boven, onder)
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
if em:
|
if em:
|
||||||
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
await ctx.channel.send(ctx.author.mention, embed=em)
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=True)
|
@commands.command(pass_context=True, hidden=True)
|
||||||
@asyncio.coroutine
|
async def eriku(self, ctx, boven: str, onder: str):
|
||||||
def eriku(self, ctx, boven: str, onder: str):
|
|
||||||
"""Maakt een erik meem.
|
"""Maakt een erik meem.
|
||||||
Bijvoorbeeld:
|
Bijvoorbeeld:
|
||||||
!eriku \"je moeder\" \"is een hoer\"
|
!eriku \"je moeder\" \"is een hoer\"
|
||||||
"""
|
"""
|
||||||
em = self.get_imgflip_embed(self.imgflips['eriku'], boven, onder)
|
em = self.get_imgflip_embed(self.imgflips['eriku'], boven, onder)
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
if em:
|
if em:
|
||||||
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
await ctx.channel.send(ctx.author.mention, embed=em)
|
||||||
|
|
||||||
def get_tegeltje(self, tekst, auteur):
|
def get_tegeltje(self, tekst, auteur):
|
||||||
params = {
|
params = {
|
||||||
@@ -341,43 +330,39 @@ class Shitpost(commands.Cog):
|
|||||||
return self.get_imgflip_embed(self.imgflips['tegeltje'], "", "", params)
|
return self.get_imgflip_embed(self.imgflips['tegeltje'], "", "", params)
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=True)
|
@commands.command(pass_context=True, hidden=True)
|
||||||
@asyncio.coroutine
|
async def tegeltje(self, ctx, tekst: str, auteur: str=" "):
|
||||||
def tegeltje(self, ctx, tekst: str, auteur: str=" "):
|
|
||||||
"""Maak een mooi tegeltje met volkswijsheid
|
"""Maak een mooi tegeltje met volkswijsheid
|
||||||
Bijvoorbeeld:
|
Bijvoorbeeld:
|
||||||
!tegeltje \"Oost west, 420 best\" \"Lourens\"
|
!tegeltje \"Oost west, 420 best\" \"Lourens\"
|
||||||
"""
|
"""
|
||||||
em = get_tegeltje(tekst, auteur)
|
em = self.get_tegeltje(tekst, auteur)
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
if em:
|
if em:
|
||||||
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
await ctx.channel.send(ctx.author.mention, embed=em)
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=True)
|
@commands.command(pass_context=True, hidden=True)
|
||||||
@asyncio.coroutine
|
async def zout(self, ctx, boven: str, onder: str):
|
||||||
def zout(self, ctx, boven: str, onder: str):
|
|
||||||
"""Maakt een martijn-zout meem.
|
"""Maakt een martijn-zout meem.
|
||||||
Bijvoorbeeld:
|
Bijvoorbeeld:
|
||||||
!zout \"je moeder\" \"is een hoer\"
|
!zout \"je moeder\" \"is een hoer\"
|
||||||
"""
|
"""
|
||||||
em = self.get_imgflip_embed(self.imgflips['zout'], boven, onder)
|
em = self.get_imgflip_embed(self.imgflips['zout'], boven, onder)
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
if em:
|
if em:
|
||||||
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
await ctx.channel.send(ctx.author.mention, embed=em)
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=True)
|
@commands.command(pass_context=True, hidden=True)
|
||||||
@asyncio.coroutine
|
async def nihao(self,ctx):
|
||||||
def nihao(self,ctx):
|
await ctx.channel.send("kankerlauw")
|
||||||
yield from ctx.channel.send("kankerlauw")
|
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
async def tijd(self, ctx, *args):
|
||||||
def tijd(self, ctx, *args):
|
|
||||||
"""Vertelt je hoe laat het is..
|
"""Vertelt je hoe laat het is..
|
||||||
Misschien geeft het ook wel een leuke meem terug.
|
Misschien geeft het ook wel een leuke meem terug.
|
||||||
Wie weet.
|
Wie weet.
|
||||||
@@ -398,20 +383,20 @@ class Shitpost(commands.Cog):
|
|||||||
elif os.path.isfile(filepng):
|
elif os.path.isfile(filepng):
|
||||||
filepath = filepng
|
filepath = filepng
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
if filepath != '':
|
if filepath != '':
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' Het is nu ' + datetime.now().strftime('%H:%M'), file=discord.File(filepath, 'tijd.png'))
|
await ctx.channel.send(ctx.author.mention + ' Het is nu ' + datetime.now().strftime('%H:%M'), file=discord.File(filepath, 'tijd.png'))
|
||||||
else:
|
else:
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' Het is nu ' + datetime.now().strftime('%H:%M'))
|
await ctx.channel.send(ctx.author.mention + ' Het is nu ' + datetime.now().strftime('%H:%M'))
|
||||||
|
|
||||||
def get_dice_roll(self, nrOfDice, dieType, modifier=None):
|
def get_dice_roll(self, nrOfDice, dieType, modifier=None):
|
||||||
if nrOfDice > 99 or dieType > 9999 or dieType < 2 or (modifier and abs(modifier) > 9999):
|
if nrOfDice > 99 or dieType > 9999 or dieType < 2 or (modifier and abs(modifier) > 9999):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Do the rolling
|
# Do the rolling
|
||||||
random.seed(datetime.now())
|
random.seed(datetime.now().timestamp())
|
||||||
total = 0
|
total = 0
|
||||||
rolls = []
|
rolls = []
|
||||||
for x in range(0, nrOfDice):
|
for x in range(0, nrOfDice):
|
||||||
@@ -447,8 +432,7 @@ class Shitpost(commands.Cog):
|
|||||||
return (numDice, die, modifier)
|
return (numDice, die, modifier)
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
async def roll(self, ctx, *, dice):
|
||||||
def roll(self, ctx, *, dice):
|
|
||||||
"""Roll een dobbelsteen. Of een paar. Bijvoorbeeld:
|
"""Roll een dobbelsteen. Of een paar. Bijvoorbeeld:
|
||||||
!roll 4d20
|
!roll 4d20
|
||||||
!roll 1d6 + 5
|
!roll 1d6 + 5
|
||||||
@@ -456,9 +440,9 @@ class Shitpost(commands.Cog):
|
|||||||
(nrOfDice, dieType, modifier) = self.get_dice_parameters(dice)
|
(nrOfDice, dieType, modifier) = self.get_dice_parameters(dice)
|
||||||
message = self.get_dice_roll(nrOfDice, dieType, modifier)
|
message = self.get_dice_roll(nrOfDice, dieType, modifier)
|
||||||
if message:
|
if message:
|
||||||
yield from ctx.channel.send(message)
|
await ctx.channel.send(message)
|
||||||
else:
|
else:
|
||||||
yield from ctx.channel.send("Die roll vind ik echt een beetje te mal..")
|
await ctx.channel.send("Die roll vind ik echt een beetje te mal..")
|
||||||
|
|
||||||
def get_weerbericht(self, wData, verbose=None):
|
def get_weerbericht(self, wData, verbose=None):
|
||||||
if not wData:
|
if not wData:
|
||||||
@@ -519,8 +503,7 @@ class Shitpost(commands.Cog):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
async def weer(self, ctx, location="Leiden", verbose=None):
|
||||||
def weer(self, ctx, location="Leiden", verbose=None):
|
|
||||||
"""Vertelt je het weer.
|
"""Vertelt je het weer.
|
||||||
Omdat je te lui bent om naar buiten te kijken.
|
Omdat je te lui bent om naar buiten te kijken.
|
||||||
Oant Moarn!
|
Oant Moarn!
|
||||||
@@ -530,7 +513,7 @@ class Shitpost(commands.Cog):
|
|||||||
message = self.get_weerbericht(wData, verbose)
|
message = self.get_weerbericht(wData, verbose)
|
||||||
if not wData or not message:
|
if not wData or not message:
|
||||||
message = "Weer ophalen niet gelukt. Probeer het later nogmaals.."
|
message = "Weer ophalen niet gelukt. Probeer het later nogmaals.."
|
||||||
yield from ctx.channel.send(message)
|
await ctx.channel.send(message)
|
||||||
|
|
||||||
#returns a nice weather icon. Sometimes the API uses non-documented icons, so we return something else
|
#returns a nice weather icon. Sometimes the API uses non-documented icons, so we return something else
|
||||||
def getWeatherIconTranslation(self, iconKey):
|
def getWeatherIconTranslation(self, iconKey):
|
||||||
@@ -610,27 +593,25 @@ class Shitpost(commands.Cog):
|
|||||||
return zwarte_kaart.replace("___", "**{}**").format(*wit)
|
return zwarte_kaart.replace("___", "**{}**").format(*wit)
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
async def ktdm(self, ctx, *args):
|
||||||
def ktdm(self, ctx, *args):
|
|
||||||
'''Speel Kaarten Tegen De Mensheid! Genereer een kaart of geef zelf opties.
|
'''Speel Kaarten Tegen De Mensheid! Genereer een kaart of geef zelf opties.
|
||||||
Bijvoorbeeld: !ktdm <"1"><"2"><"3"> (aanbevolen 1 of 2, max 3)'''
|
Bijvoorbeeld: !ktdm <"1"><"2"><"3"> (aanbevolen 1 of 2, max 3)'''
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
resultaat = self.get_ktdm(args)
|
resultaat = self.get_ktdm(args)
|
||||||
if resultaat:
|
if resultaat:
|
||||||
yield from ctx.channel.send(f"{ctx.author.mention}\n{resultaat}")
|
await ctx.channel.send(f"{ctx.author.mention}\n{resultaat}")
|
||||||
else:
|
else:
|
||||||
yield from ctx.channel.send(f"{ctx.author.mention}\nIets ging niet helemaal lekker")
|
await ctx.channel.send(f"{ctx.author.mention}\nIets ging niet helemaal lekker")
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
async def beledig(self, ctx, member:discord.User):
|
||||||
def beledig(self, ctx, member:discord.User):
|
|
||||||
'''Je vindt iemand stom maar je hebt geen inspiratie? Beledig al je vriendjes met deze handige beledig-i-fier!
|
'''Je vindt iemand stom maar je hebt geen inspiratie? Beledig al je vriendjes met deze handige beledig-i-fier!
|
||||||
Bijvoorbeeld: !beledig @jemoeder'''
|
Bijvoorbeeld: !beledig @jemoeder'''
|
||||||
yield from ctx.channel.send(member.mention+ ", " + ctx.author.mention + " vindt jou een " + random.choice(self.insult) + "! :angry:")
|
await ctx.channel.send(member.mention+ ", " + ctx.author.mention + " vindt jou een " + random.choice(self.insult) + "! :angry:")
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
|
|
||||||
def get_watspelenwe_cal(self):
|
def get_watspelenwe_cal(self):
|
||||||
"""Geeft een paar terug, met de titel en omschrijving van het eerstvolgende event uit de kalender"""
|
"""Geeft een paar terug, met de titel en omschrijving van het eerstvolgende event uit de kalender"""
|
||||||
@@ -749,8 +730,7 @@ class Shitpost(commands.Cog):
|
|||||||
return message
|
return message
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
async def watspelenwe(self, ctx):
|
||||||
def watspelenwe(self, ctx):
|
|
||||||
"""Stroop weet wat we spelen op vrijdag.
|
"""Stroop weet wat we spelen op vrijdag.
|
||||||
Geeft elke week een pseudo-random antwoord.
|
Geeft elke week een pseudo-random antwoord.
|
||||||
Geseed op weeknummer + jaar.
|
Geseed op weeknummer + jaar.
|
||||||
@@ -764,10 +744,10 @@ class Shitpost(commands.Cog):
|
|||||||
message += ". En wilt iemand even aan Mark vragen of hij de kalender bijhoudt?"
|
message += ". En wilt iemand even aan Mark vragen of hij de kalender bijhoudt?"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
await ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
yield from ctx.channel.send(message)
|
await ctx.channel.send(message)
|
||||||
|
|
||||||
def get_review_string(self, topic = ""):
|
def get_review_string(self, topic = ""):
|
||||||
if topic == "":
|
if topic == "":
|
||||||
@@ -819,10 +799,9 @@ class Shitpost(commands.Cog):
|
|||||||
return message
|
return message
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
async def review(self, ctx, *args):
|
||||||
def review(self, ctx, *args):
|
|
||||||
"""Stroop heeft (bijna) overal een mening over. Vraag het hem!
|
"""Stroop heeft (bijna) overal een mening over. Vraag het hem!
|
||||||
"""
|
"""
|
||||||
topic = " ".join(args)
|
topic = " ".join(args)
|
||||||
message = self.get_review_string(topic)
|
message = self.get_review_string(topic)
|
||||||
yield from ctx.channel.send(message)
|
await ctx.channel.send(message)
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ class TestShitpost(unittest.TestCase):
|
|||||||
def test_watspelenwe_cal(self):
|
def test_watspelenwe_cal(self):
|
||||||
data = requests.get(os.getenv('STROOP_CALDAV_CAL'))
|
data = requests.get(os.getenv('STROOP_CALDAV_CAL'))
|
||||||
if not data:
|
if not data:
|
||||||
self.skipTest(f"Server at {self.cog.muzak_url} has an error, or is unavailable")
|
self.skipTest(f"Server at {os.getenv('STROOP_CALDAV_HOST')} has an error, or is unavailable")
|
||||||
|
|
||||||
(activiteit, reden) = self.cog.get_watspelenwe_cal()
|
(activiteit, reden) = self.cog.get_watspelenwe_cal()
|
||||||
with self.subTest(msg="Watspelenwe activiteit does not return a string"):
|
with self.subTest(msg="Watspelenwe activiteit does not return a string"):
|
||||||
|
|||||||
Reference in New Issue
Block a user