Giet het al oan?

This commit is contained in:
2018-02-06 22:25:03 +01:00
parent 6ded0fee8e
commit aa834cf173
+27 -1
View File
@@ -2,6 +2,8 @@ import asyncio
import discord import discord
from discord.ext import commands from discord.ext import commands
from urllib import request from urllib import request
import requests
import oauth2 as oauth
import json, requests import json, requests
from datetime import datetime from datetime import datetime
import sys import sys
@@ -15,7 +17,31 @@ class Shitpost(object):
self.voice_states = {} self.voice_states = {}
def __check(self, ctx): #Todo: Is dit het shitpost kanaal? def __check(self, ctx): #Todo: Is dit het shitpost kanaal?
return True return True
@commands.command(pass_context=True, hidden=False)
@asyncio.coroutine
def giethetaloan(self, ctx):
"""Giet het al oan?
Ja of Nee.. kom op nou.
"""
#We halen dit op van de twitter account @gietitaloan die vertrouwen wij als de ultieme waarheid
#hahaha geheime tokens in de code hahahaha TODO
consumer = oauth.Consumer(key="eUotijxUEcTVpegNCIzEqz0be", secret="Opj95FAhRkpgVpo61PEJcConvYHgAk7TlouETk2NaSh6dvhCLu")
client = oauth.Client(consumer)
resp, content = client.request("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=gietitaloan&count=1", "GET")
#TODO kijken of resp iets zinnigs teruggeeft.. of iets doen met een try of catch ofzow
content_str = content.decode('utf-8') #converteren naar str voor welke stomme reden dan ook
answer = json.loads(content_str)[0]["text"] #inhoud van de tweet
answer = answer.lower()
reactie = ""
if 'ja' in answer:
if 'nee' in answer:
reactie += 'Het is onduidelijk..'
else:
reactie += 'Het giet oan!'
else:
if 'nee' in answer:
reactie += 'Nee helaas..'
yield from ctx.channel.send(ctx.author.mention + ' ' + reactie)
@commands.command(pass_context=True, hidden=True) @commands.command(pass_context=True, hidden=True)
@asyncio.coroutine @asyncio.coroutine
def mark(self, ctx, boven: str, onder: str): def mark(self, ctx, boven: str, onder: str):