Files
stroopwafel/General.py
T
mark b08933b9f1 Verwijder tex
Gebruikt niemand, en vergt 10 gigabyte installs om lokaal te testen
2022-12-04 16:31:04 +01:00

108 lines
3.1 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
from sympy import latex, symbols, preview, Symbol #for LaTeX images
import youtube_dl
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
@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:
"""
id = re.search("\<\:([A-z]*)\:(\d*)\>", arg)
hugemoji = 'https://cdn.discordapp.com/emojis/' + id.group(2) + '.png'
em = discord.Embed(title=id.group(1), type='photo')
em.set_image(url=hugemoji)
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)