import asyncio import discord import sys, os import praw import random from discord.ext import commands from sympy import latex, symbols, preview, Symbol #for LaTeX images class General(object): """Overal toegestaan.""" def __init__(self, bot): self.bot = bot self.voice_states = {} self.r = praw.Reddit( user_agent='StroopwafelBot', client_secret='Z4K17T8TC26cNAgDSRxCkE9jYR4', client_id='aWeyKpzdHMtmJQ' ) self.r.read_only = True f = open("password.txt","r") self.rebootPW = f.readline() def __check(self, ctx): #Todo: Is dit het porno kanaal? return True @commands.command() @asyncio.coroutine def tex(self, ctx, *, arg): """Geeft een mooi LaTeX plaatje terug. Bijvoorbeeld: !tex Je moeder is lelijk! $a^b b^c \\rightarrow d$ """ preamble = "\\documentclass[10pt]{article}\\pagestyle{empty}\\usepackage[margin=1in]{geometry}\\usepackage{amsmath, amsfonts}\\begin{document}" #\\usepackage{CJKutf8}\\usepackage[T1]{fontenc}\\usepackage[english]{babel} options = ["-T", "tight", "-z", "9", "--truecolor", "-D", "512"] preview(r''+arg+'', viewer='file', filename='test.png', dvioptions=options, preamble=preamble) #file = open('test.png', 'rb') #yield from ctx.channel.send(file, filename ='test.png', content='') try: yield from ctx.message.delete() except: print("No permission to delete message") yield from ctx.channel.send(ctx.author.mention, file=discord.File('test.png', 'tex.png')) @commands.command(pass_context=True) @asyncio.coroutine def aww(self, ctx): """ iets schattigs... """ print(type(ctx.message.channel)) raww = self.r.subreddit('aww+catloaf+tuckedinkitties+babyelephantgifs+babybigcatgifs+blep+holdmynip+gingerkitty+cathighfive+catsstandingup+catsareassholes+eyebleach') post = raww.top('month', limit=250) listing = list(post) random.shuffle(listing) post = listing[0] try: yield from ctx.message.delete() except: print("No permission to delete message") yield from ctx.channel.send(ctx.author.mention + ' ' + post.url) @commands.command(pass_context=True, hidden=True) @asyncio.coroutine def reboot(self, ctx, password=""): """ Reboot.. """ print(self.rebootPW) if password == self.rebootPW: yield from ctx.channel.send("Rebooting.. brb!") os.execv(sys.executable, ['python3'] + sys.argv) else: yield from ctx.channel.send(ctx.author.mention + " What's the magic word?")