Render TeX Formulas in Telegram Chats
Once the Telegram Bot (https://t.me/liwde_math_bot) is started, it listens for Messages starting with /math, typeset any TeX passed and respond with an image.
The Bot is powered by MathJax and supports every command it is capable of. A full list can be found here: http://docs.mathjax.org/en/latest/tex.html
/math \nabla w_{pq}=-\eta\frac{\partial E}{\partial w_{pq}}Some texts for /start and /help are provided in index.js. Secret configuration must be passed through environment variables:
BOT_TOKEN: The Telegram Token generated by the BotFatherMATOMO_URL(optional): BaseURL of the Matomo Installation to which the Bot will report anonymous usage statisticsMATOMO_SITE_ID(optional): Site ID for the Telegram Bot in MatomoMATOMO_TOKEN(optional): Authorization Token to write to Matomo
Telegram supports a concept called Inline Bots – special Bots to be summoned in any Chat to provide capabilities such as a Wikipedia or a Gif search. However, there are a few limitations on this technology:
- You must provide autocomplete: This means, that the Bot would have to typeset each intermediate formula in the textbox while the user is typing. This results in lots of additional load on the Bot
- You must use JPG: This Bot converts all the images to PNG. In order to use the Inline Bot, it would need to recode the images to JPG, which is more lossy
- You must host the images: Currently, the Bot directly streams the images to the Telegram API. With Inline Bots, the images must be hosted at a webserver from which Telegram will fetch them.
As I consider the effort of implementing an Inline Bot combined with the downsides listed above greater than the benefits of having an Inline Bot, MathBot will not support this feature.
If you want to send a typeset formula to a friend in a dialog, just send the TeX to the MathBot itself and forward the resulting image. In Group Conversations, however, you can simply add the MathBot, where it will respond to all your /math-related messages.