/home_bot

My personal telegram bot to be run at home with some simple functionalities

Primary LanguagePython

Home BOT

This is a very simple bot for Telegram that I created just to be able to ask via Telegram which is my IP address.

As I access my Raspberry Pi remotely daily I need to know my IP address to be able to connect via SSH, and as my ISP do not lock my IP statically (without paying a very expensive tax), every time there is a surge of power or a service maintenance my external IP changes.

This script is always executed on my Raspbian at boot-up and keeps running, and then I'm always able to ask my actual home IP numbers.

I will probably add more functionalities as I see fit, but for now it only tells me my IP.

When executed the python main sends with the Telegram bot a message containing the current IP, and every 10 min it registers it again and check if it has changed, if so, it sends another message with the new IP address.

Commands that should be sent as Telegram messages

ip --- bot answers with it's external IP

api_key.py

A file should be created that contains two important variables.

  • TOKEN (this contains the API key Token generated by BotFather on Telegram)
  • ID (this holds the chat ID of the bot owner)

The bot only responds a command with the right output, after checking if the chat ID is the one listed on the api_key.py. This makes a simple but very effective security measure.