Hi, i'm trying to use mathmode on Telegram.
When i send a command, execute this code:
const fs = require('fs');
exports.execute = (bot, msg, match) => {
var path = __dirname + '\\latex\\' + Gen(10) + '.png';
var dest = fs.createWriteStream(path);
var render = require("mathmode")(match[1]).pipe(dest);
render.on('finish', function () {
bot.sendPhoto(msg.chat.id, fs.createReadStream(path));
});
function Gen(num){
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
for( var i=0; i < num; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
};
match[1] is the sentence (like x^2 + 3x + 1).
The bot create an image on the directory, but it create an empty image (0 bits, and when i open on Paint, it is in white).
What I'm doing wrong?
Hi, i'm trying to use mathmode on Telegram.
When i send a command, execute this code:
match[1] is the sentence (like x^2 + 3x + 1).
The bot create an image on the directory, but it create an empty image (0 bits, and when i open on Paint, it is in white).
What I'm doing wrong?