4b5e4cf407
continuous-integration/drone/push Build is passing
Onder andere youtubedl en ffmpeg voor de gif, en de latex sympy. Deze changes zijn ook doorgevoerd in de readme.
111 lines
3.2 KiB
Python
111 lines
3.2 KiB
Python
import asyncio
|
|
import discord
|
|
import sys, os
|
|
import praw
|
|
import random
|
|
import re
|
|
import json, requests
|
|
import warnings
|
|
from discord.ext import commands
|
|
|
|
class General(commands.Cog):
|
|
"""Overal toegestaan."""
|
|
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
self.voice_states = {}
|
|
self.muzak_url = 'https://hdcon-muzak.herokuapp.com'
|
|
self.r = praw.Reddit(
|
|
user_agent='StroopwafelBot',
|
|
client_secret=os.getenv("STROOP_REDDIT_SECRET"),
|
|
client_id=os.getenv("STROOP_REDDIT_ID")
|
|
)
|
|
self.r.read_only = True
|
|
warnings.simplefilter("ignore")
|
|
|
|
def __check(self, ctx): #Todo: Is dit het porno kanaal?
|
|
return True
|
|
|
|
def get_emoji_embed(self, tag: str):
|
|
emoji = re.search(".*\<\:([A-z]*)\:(\d*)\>.*", tag)
|
|
embed = discord.Embed(title=emoji.group(1), type='photo')
|
|
hugemoji = 'https://cdn.discordapp.com/emojis/' + emoji.group(2) + '.png'
|
|
embed.set_image(url=hugemoji)
|
|
return embed
|
|
|
|
|
|
@commands.command()
|
|
@asyncio.coroutine
|
|
def huge(self, ctx, *, arg):
|
|
"""YUGE. Geeft een grote versie van de gegeven emoji terug. Werkt alleen voor custom emoji.
|
|
Bijvoorbeeld:
|
|
!huge :ancilla:
|
|
"""
|
|
em = self.get_emoji_embed(arg)
|
|
try:
|
|
yield from ctx.message.delete()
|
|
except:
|
|
print("No permission to delete message")
|
|
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
|
|
|
def get_aww_post(self):
|
|
raww = self.r.subreddit('aww+catloaf+tuckedinkitties+babyelephantgifs+babybigcatgifs+blep+holdmynip+gingerkitty+cathighfive+catsstandingup+catsareassholes+eyebleach')
|
|
listing = list(raww.top(time_filter='month'))
|
|
return random.choice(listing)
|
|
|
|
@commands.command(pass_context=True)
|
|
@asyncio.coroutine
|
|
def aww(self, ctx):
|
|
""" iets schattigs... """
|
|
post = self.get_aww_post()
|
|
try:
|
|
yield from ctx.message.delete()
|
|
except:
|
|
print("No permission to delete message")
|
|
yield from ctx.channel.send(ctx.author.mention + ' ' + post.url)
|
|
|
|
def get_kopieerpasta(self):
|
|
rkopieerpasta = self.r.subreddit('kopieerpasta')
|
|
post = rkopieerpasta.random()
|
|
|
|
# Subreddits kunnen de random functie uitzetten, dus dit is de fallback:
|
|
if post == None:
|
|
listing = list(rkopieerpasta.top('month', limit=250))
|
|
post = random.choice(listing)
|
|
|
|
return post
|
|
|
|
@commands.command(pass_context=True)
|
|
@asyncio.coroutine
|
|
def kopieerpasta(self, ctx):
|
|
"""Een willekeurige shitpost"""
|
|
post = self.get_kopieerpasta()
|
|
print(post.url)
|
|
ATTEMPTS = 10
|
|
a = 0
|
|
while len(post.selftext + post.title) >= 1990 and a < ATTEMPTS:
|
|
post = self.get_kopieerpasta()
|
|
print(post.url)
|
|
a += 1
|
|
try:
|
|
yield from ctx.message.delete()
|
|
except:
|
|
print("No permission to delete message")
|
|
|
|
if len(post.selftext + post.title) < 1990:
|
|
yield from ctx.channel.send('**'+post.title+'**```'+post.selftext+'```')
|
|
else:
|
|
yield from ctx.channel.send("Geen kopieerpasta voor jou vandaag.")
|
|
|
|
def get_playlist_json(self):
|
|
return requests.get(self.muzak_url + '/stroopwafel')
|
|
|
|
@commands.command(pass_context=True)
|
|
@asyncio.coroutine
|
|
def playlist(self, ctx):
|
|
"""HDcon2021 playlist"""
|
|
data = json.loads(self.get_playlist_json().content)
|
|
msg = 'Stemmen en nomineren kan hier: {}\n'.format(self.muzak_url)
|
|
msg += '*Er zijn al {} nummers genomineerd*\n'.format(data['stemCount'])
|
|
yield from ctx.channel.send(msg)
|