Giter Club home page Giter Club logo

send-your-ip's Introduction

Send your IP

Sends your IP to a Telegram bot you own. It's useful to connect your Raspberry Pi when you don't know how to leave it with a static IP.

How it works

To make this code work you must change the lines 31 & 32 with the variables token and user respectively.

Getting your token

To get a token, enter to your Telegram account and look for @BotFather. Create a new token with the command '/newbot' then just follow the instructions and you will get a token.

Getting your user id

Look for the bot @JsonDumpBot , and you will receive a message that will include the parameter "message"{"chat":{"id"}}. This number is you user id.

After getting these items, add them to the file, and run it.

Taking advantage in a Raspberry Pi.

To use this as a daemon each time you run your Raspberry Pi, you must follow these instructions in the terminal: First save the main file as .ip.py (the dot before the name is to hide the file instead of having it public) in your folder /home/YOUR-USER-DIRECTORY. run the command sudo nano /etc/systemd/system/ip.service and write in it this content:

[Unit]
Description=Sends IP
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=idle
WorkingDirectory=/home/YOUR-USER-DIRECTORY
ExecStart=/usr/bin/python3 /home/YOUR-USER-DIRECTORY/.ip.py
Restart=on-failure

[Install]
WantedBy=multi-user.target

Then save it. Now run:

systemctl enable ip
systemctl daemon-reload

After this, reboot your raspberry pi, and you will receive the message to your Telegram account.

Notice that this will only work when you're connecting to a network already registered in your Raspberry Pi, so first you will need to run your Raspberry Pi to make all this process. After it, next time you just turn on your Raspberry Pi it will send the message automatically without any other reuirement.

send-your-ip's People

Contributors

gfant avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.