Files
stroopwafel/pi/Shitpost.py
T

72 lines
2.2 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)
@asyncio.coroutine
def eriku(self, ctx, boven: str, onder: str):
"""Maakt een erik meem.
Bijvoorbeeld:
@Stroopwafel 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)
yield from self.bot.say(embed=em)
@commands.command(pass_context=True, hidden=True)
@asyncio.coroutine
def nihao(self,ctx):
yield from self.bot.say("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
if filepath is not '':
file = open(filepath, 'rb')
yield from self.bot.upload(file, filename = filepath)
else:
yield from self.bot.say('Het is nu ' + datetime.now().strftime('%H:%M'))