Shterneregen / telegram-home-bot

Telegram bot that provides simple monitoring of hosts in your network and allows you to execute commands on the bot-machine
4 stars 0 forks source link
google-charts h2-database home-automation kotlin openweathermap-api spring-boot spring-security telegram-bot thymeleaf wake-on-lan webflux

CircleCI

Telegram Home Bot

Can be used for home automation on Raspberry Pi

What can this bot do?

Application settings are stored in application.properties file

How to set up the project

Create telegram chatbot

Admin site in browser

Enable network monitor

What does network monitor do?

Run commands on chatbot machine

Wake On Lan feature

Enable Weather menu

List of chatbot commands


Additional information

Installation as an init.d Service

sudo mkdir /var/telegram # create a folder for jar file
sudo cp /SOME_LINUX_FOLDER/thb.jar /var/telegram/thb.jar # copy jar to the folder
sudo ln -s /var/telegram/thb.jar /etc/init.d/thb # create symlink the jar to init.d
sudo chmod +x /var/telegram/thb.jar # make thb.jar executable
sudo systemctl daemon-reload # reload systemd manager configuration
sudo service thb start # start bot as a service
update-rc.d thb defaults # autostart

Enable HTTPS

The example below will be with a self-signed certificate on the local machine

keytool -genkeypair -alias thb -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore thb-keystore.p12 -validity 3650 -ext san=ip:127.0.0.1

Launch bot in Docker

# Build the image
docker build -t thb-image .

# Create and start new container from the image
docker run -d -p 80:8080 --network=bridge --name=thb  thb-image

# Start the container
docker start thb

# Stop the running container
docker stop thb

# Show information logged by a running container
docker logs -f thb

Launch SonarQube in Docker

docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 sonarqube
gradlew sonarqube -Dsonar.projectKey=thb -Dsonar.host.url=http://127.0.0.1:9000 -Dsonar.login=PROJECT_TOKEN

Create private chat group with chatbot (JFYI)


Preview (outdated)

Commands

Hosts

TimeLog


Kotlin, Spring (Boot/Security/WebFlux), Gradle, H2, Thymeleaf, Google Charts, telegrambots-spring-boot-starter