Nestor

Mon petit bot Discord
Log | Files | Refs

commit b480e6f9438aefab7296eb14a557e967bdc4ec3a
parent 7f54928bcc8f540ed8e93159910d14fb19da96ce
Author: Doshirae <doshirae@doshirae.fr>
Date:   Wed, 10 Oct 2018 12:30:49 +0200

Latex command : now white foreground

Diffstat:
Nestor.rb | 4++--
commandes.rb | 15+++++++++++----
2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/Nestor.rb b/Nestor.rb @@ -190,8 +190,8 @@ end # latex {{{ bot.command(:latex, description: "Renvoie une image avec du LaTeX [EXPERIMENTAL, n'utiliser que du latex, pas d'unicode]", usage: "!latex <latex>") do |event, *latex| latex(latex) - event.channel.send_file File.new('latex.png') - `rm latex.png` + event.channel.send_file File.new('output.png') + `rm output.png` end # }}} diff --git a/commandes.rb b/commandes.rb @@ -93,10 +93,6 @@ $$) + input + %q($$ \end{document} ) - def download_file(file) - system(%Q(wget -O latex.png "http://rtex.probablyaweb.site/api/v2/#{file}")) - end - uri = URI("http://rtex.probablyaweb.site/api/v2") payload = { 'code' => latex, 'format' => 'png' }.to_json req = Net::HTTP.post(uri, payload, "Content-Type" => "application/json") @@ -107,3 +103,14 @@ $$) + input + %q($$ file = response["filename"] download_file(file) end + +def download_file(file) + system(%Q(wget -O latex.png "http://rtex.probablyaweb.site/api/v2/#{file}")) + convert_file("latex.png") + File.delete("latex.png") +end + +def convert_file(file) + system("convert latex.png -channel rgb -negate +channel output.png") +end +