A Telegram bot to generate messages using Markov chains
Creating a bot is done through @BotFather. See the official documentation for more details.
Important
Privacy mode has to be disabled so that the bot can store user messages to generate its replies from.
-
Send
/setcommandsto @BotFather. -
Select this bot.
-
Enter the commands that are registered in the bot (using
bot.command()):settings - Adjust bot settings
stats - View stats about the bot's activity in your group
Important
Make sure to perform the steps above, otherwise users won't be able to configure the bot's settings.
-
Install dependencies:
yarn install
-
Add the database URL and your bot token from BotFather to the
.envfile in the project directory:DATABASE_URL="file:database/store.db" TOKEN=<insert your Telegram bot token here>
-
Follow the steps in the Project installation section.
-
Start the bot in development mode:
yarn run dev
yarn run generate-migrationsImportant
Make sure to run the command above before every deployment.
Follow the steps below in the deployment environment.
-
Follow the steps in the Project installation section.
-
Build the bot:
yarn run build
-
Run
build/index.jsusing your preferred method. (For example, to run with Node.js:node --enable-source-maps build/index.js)
The process of adding the bot user is the same as adding any other user.
By default, the bot replies with a generated message when it is @mentioned.
For more information on how to adjust reply settings see Bot configuration.
Send /settings in the group chat to access the bot's settings menu and configure its settings for that group.
- Reply on mention: Reply when the bot is mentioned.
- Reply randomly: Send a message when the number of messages sent in the group reaches a certain amount since the bot's last message.
- Admin-only settings: Allow setting changes only by group admins.
- Admin-only bot commands: Allow the bot's commands to be used only by group admins.