Skip to content

Telegram chatbot using a Markov chain for automatic replies (similar to Peka)

Notifications You must be signed in to change notification settings

leventea/markovbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MarkovBot

A Telegram bot that trains a markov chain on your group chat.

Running

  • Clone the repository and configure the bot in config/config.exs.
  • Run mix deps.get to install the dependencies
  • mix run to run normally OR iex -S mix for a REPL

Training the bot on a Telegram export

The MarkovBot.Utilities module contains a helper function that trains the bot on a JSON Telegram export. From a REPL, run:

# NOTE: in case you wish to return to the previous state of the chain,
# you can use a named backup, since they will not get purged
MarkovBot.Scheduler.Tasks.backup("backup_name")

MarkovBot.Utilities.train_from_telegram("path/to/file.json") # relative paths can be used

MarkovBot.Scheduler.Tasks.autosave # force an auto-save to write the updated chain to disk

Updating the configuration at runtime

You can update the config at runtime with built-in Elixir utilities from the Application module, but be aware it will not write your changes into config/config.exs, in order to make your changes persistent you will have to edit it manually.

Application.put_env(:markov_bot, :admins, [ 12345 ]) # overwrite the list of admins

Defaults

By default the built-in cron service will auto-save the chain to disk every 15 minutes, create a backup every day, and purge old backups every week (which are kept for 7 days by default)

About

Telegram chatbot using a Markov chain for automatic replies (similar to Peka)

Resources

Stars

Watchers

Forks

Languages