The current bot name is dv-wiki-bot. DV stands for "Digital Volunteers".
The Notion wiki is here.
The Java library TelegramBots is used as the Telegram API wrapper.
The useful "Getting Started" for this library — https://github.com/rubenlagus/TelegramBots/wiki/Getting-Started.
To enable bot to answer ALL the messages (not only the ones starting with /),
you have to disable its privacy, using the /setprivacy command in the @BotFather.
After changing the privacy setting, you may need to remove and add the bot to the chat.
To change the bot username in Telegram, use the /setname command in the @BotFather.
To change the bot avatar in Telegram, use the /setuserpic command in the @BotFather.
The bot runs as a simple Java Main class.
Set the environment variable WIKI_BOT_CONFIG_FILE_PATH:
export WIKI_BOT_CONFIG_FILE_PATH=/path/to/your/file/wiki-bot-config.jsonIn the json config, set environmentName property to indicate the environment:
"environmentName": "My local super environment",and botToken for your bot instance (test, prod, etc)
"botToken": "1234567890:AAFxrf7...",Execute the java Main class from the jar file.
You can override the log4j configuration via the log4j.configurationFile property.
java -Dlog4j.configurationFile=./log4j2-override.xml -jar wiki-telegram-bot-1.0-SNAPSHOT-jar-with-dependencies.jarhttps://docs.aws.amazon.com/corretto/latest/corretto-17-ug/amazon-linux-install.html
https://asf.alaska.edu/how-to/data-recipes/connect-to-your-ec2-instance-using-putty-v1-1/
And then login under ec2-user.
See https://linuxize.com/post/how-to-use-linux-screen/
We have to run the java process of the bot in a separate screen session to not drop it after we disconnected from PuTTY.
Copy bot files to the EC2 instance using the copy-to-ec2.sh file.
Log in to the EC2 instance using PuTTY, username ec2-user.
Go to the bot directory
cd /home/ec2-user/wiki-botCreate a screen session for the bot:
screen -S wiki-botMake sure you've set up the environment variable:
export WIKI_BOT_CONFIG_FILE_PATH="/home/ec2-user/wiki-bot/wiki-bot-config.json"Run the bot using the run-ec2.sh script
source ./run-ec2.shDisconnect from the current screen session: Ctrl + A, D.
You can watch the logs of the bot:
tail -f ./wiki-bot.logNow you can disconnect from PuTTY and the bot will continue to work!
To stop the bot, connect to PuTTY again.
Get back to the screen session:
screen -r wiki-botAnd press Ctrl + C to stop the bot.
- Define the bot name and whether the bot should be male/female.
- Define the bot default settings.
- Create the new bot,
/newbotin the @BotFather. - Set bot name via
/setnamein the @BotFather. - Disable bot privacy using
/setprivacyin the @BotFather. - Set male or female bot avatar via
/setuserpicin the @BotFather. - Add bot config to the prod json config file.
- Build the maven artifact
mvn install. - Connect to EC2 via PuTTY.
- Resume the
screensession running the bot. - Stop the running bot instances with
Ctrl + C. - Deploy the new bot configuration with
copy-to-ec2.sh. - Start bot instances with
run-ec2.sh.