Files
stroopwafel/pi/General.py
T

28 lines
1.1 KiB
Python

import asyncio
import discord
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 = {}
def __check(self, ctx): #Todo: Is dit het porno kanaal?
return True
@commands.command(pass_context=True)
@asyncio.coroutine
def tex(self, ctx, mathstring):
"""Geeft een mooi LaTeX plaatje terug.
Encapsuleer uw string in mooie \"
Bijvoorbeeld:
!tex "a^b b^c \rightarrow d"
"""
preamble = "\\documentclass[10pt]{article}\\pagestyle{empty}\\usepackage[margin=1in]{geometry}\\usepackage[T1]{fontenc}\\usepackage{CJKutf8}\\usepackage[english]{babel}\\usepackage{amsmath, amsfonts}\\begin{document}"
options = ["-T", "tight", "-z", "9", "--truecolor", "-D", "512"]
preview(r'$$'+mathstring+'$$', viewer='file', filename='test.png', dvioptions=options, preamble=preamble)
file = open('test.png', 'rb')
yield from self.bot.upload(file, filename ='test.png', content='Nerd!')