From aa834cf173e4ab02dd14baec80a1852a41076ec5 Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 6 Feb 2018 22:25:03 +0100 Subject: [PATCH] Giet het al oan? --- Shitpost.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Shitpost.py b/Shitpost.py index 8f6b457..af596c0 100644 --- a/Shitpost.py +++ b/Shitpost.py @@ -2,6 +2,8 @@ import asyncio import discord from discord.ext import commands from urllib import request +import requests +import oauth2 as oauth import json, requests from datetime import datetime import sys @@ -15,7 +17,31 @@ class Shitpost(object): self.voice_states = {} def __check(self, ctx): #Todo: Is dit het shitpost kanaal? 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) @asyncio.coroutine def mark(self, ctx, boven: str, onder: str):