Skip to content

Latest commit

 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MathBot

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

Example Usage

/math \nabla w_{pq}=-\eta\frac{\partial E}{\partial w_{pq}}

Configuration

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 BotFather
  • MATOMO_URL (optional): BaseURL of the Matomo Installation to which the Bot will report anonymous usage statistics
  • MATOMO_SITE_ID (optional): Site ID for the Telegram Bot in Matomo
  • MATOMO_TOKEN (optional): Authorization Token to write to Matomo

Inline Bots

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:

  1. 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
  2. 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
  3. 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.

About

Render TeX Formulas in Telegram Chats

Resources

Stars

16 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages