136 lines
4.0 KiB
Python
136 lines
4.0 KiB
Python
import asyncio
|
|
import discord
|
|
from discord.ext import commands
|
|
from urllib import request
|
|
import json, requests
|
|
from datetime import datetime
|
|
import sys
|
|
import os
|
|
|
|
class Shitpost(object):
|
|
"""Schijtpaal commando's. Alleen bruikbaar in de daarvoor toegewezen schijtpaal kanalen."""
|
|
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
self.voice_states = {}
|
|
def __check(self, ctx): #Todo: Is dit het shitpost kanaal?
|
|
return True
|
|
|
|
@commands.command(pass_context=True, hidden=True)
|
|
@asyncio.coroutine
|
|
def mark(self, ctx, boven: str, onder: str):
|
|
"""Maakt een mark meem.
|
|
Bijvoorbeeld:
|
|
!mark \"je moeder\" \"is een hoer\"
|
|
"""
|
|
params = dict(
|
|
template_id = '112898841', #de marku
|
|
username = 'Stroopwafel',
|
|
password = 'ruyter118',
|
|
text0 = boven,
|
|
text1 = onder
|
|
)
|
|
#self.bot.say("deed ik het ding?")
|
|
resp = requests.get(url='https://api.imgflip.com/caption_image', params=params)
|
|
#todo check for success
|
|
photourl = resp.json()['data']['url']
|
|
em = discord.Embed(title='De Mark heeft gesproken.', type='photo')
|
|
em.set_image(url=photourl)
|
|
try:
|
|
yield from ctx.message.delete()
|
|
except:
|
|
print("No permission to delete message")
|
|
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
|
|
|
@commands.command(pass_context=True, hidden=True)
|
|
@asyncio.coroutine
|
|
def eriku(self, ctx, boven: str, onder: str):
|
|
"""Maakt een erik meem.
|
|
Bijvoorbeeld:
|
|
!eriku \"je moeder\" \"is een hoer\"
|
|
"""
|
|
params = dict(
|
|
template_id = '93296473', #de eriku
|
|
username = 'Stroopwafel',
|
|
password = 'ruyter118',
|
|
text0 = boven,
|
|
text1 = onder
|
|
)
|
|
#self.bot.say("deed ik het ding?")
|
|
resp = requests.get(url='https://api.imgflip.com/caption_image', params=params)
|
|
#todo check for success
|
|
photourl = resp.json()['data']['url']
|
|
em = discord.Embed(title='De Eriku heeft gesproken. Prijs hem!', type='photo')
|
|
em.set_image(url=photourl)
|
|
try:
|
|
yield from ctx.message.delete()
|
|
except:
|
|
print("No permission to delete message")
|
|
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
|
|
|
|
|
@commands.command(pass_context=True, hidden=True)
|
|
@asyncio.coroutine
|
|
def zout(self, ctx, boven: str, onder: str):
|
|
"""Maakt een martijn-zout meem.
|
|
Bijvoorbeeld:
|
|
!zout \"je moeder\" \"is een hoer\"
|
|
"""
|
|
params = dict(
|
|
template_id = '116231806', #de martijn
|
|
username = 'Stroopwafel',
|
|
password = 'ruyter118',
|
|
text0 = boven,
|
|
text1 = onder
|
|
)
|
|
#self.bot.say("deed ik het ding?")
|
|
resp = requests.get(url='https://api.imgflip.com/caption_image', params=params)
|
|
#todo check for success
|
|
photourl = resp.json()['data']['url']
|
|
em = discord.Embed(title='De Martijn heeft gesproken.', type='photo')
|
|
em.set_image(url=photourl)
|
|
try:
|
|
yield from ctx.message.delete()
|
|
except:
|
|
print("No permission to delete message")
|
|
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
|
|
|
@commands.command(pass_context=True, hidden=True)
|
|
@asyncio.coroutine
|
|
def nihao(self,ctx):
|
|
#yield from self.bot.say("Kankerlauw")
|
|
yield from ctx.channel.send("kankerlauw")
|
|
|
|
@commands.command(pass_context=True)
|
|
@asyncio.coroutine
|
|
def tijd(self, ctx, *args):
|
|
"""Vertelt je hoe laat het is..
|
|
Misschien geeft het ook wel een leuke meem terug.
|
|
Wie weet.
|
|
Probeer het eens op verschillende tijdstippen.
|
|
"""
|
|
|
|
time=datetime.now().strftime('%H%M')
|
|
for argument in args:
|
|
time = argument
|
|
filepath = ''
|
|
#filejpg = './tijd/' + time + '.jpg'
|
|
#filepng = './tijd/' + time + '.png'
|
|
filejpg = os.path.join('tijd', time) + '.jpg'
|
|
filepng = os.path.join('tijd', time) + '.png'
|
|
if os.path.isfile(filejpg):
|
|
filepath = filejpg
|
|
elif os.path.isfile(filepng):
|
|
filepath = filepng
|
|
try:
|
|
yield from ctx.message.delete()
|
|
except:
|
|
print("No permission to delete message")
|
|
if filepath is not '':
|
|
#file = open(filepath, 'rb')
|
|
#yield from self.bot.upload(file, filename = filepath)
|
|
yield from ctx.channel.send(ctx.author.mention + ' Het is nu ' + datetime.now().strftime('%H:%M'), file=discord.File(filepath, 'tijd.png'))
|
|
else:
|
|
yield from ctx.channel.send(ctx.author.mention + ' Het is nu ' + datetime.now().strftime('%H:%M'))
|
|
def setup(bot):
|
|
bot.add_cog(Shitpost(bot)) |