https://github.com/brenordv/telegram-bot-fetch-external-ip
https://github.com/brenordv/telegram-bot-fetch-external-ip
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/brenordv/telegram-bot-fetch-external-ip
- Owner: brenordv
- Created: 2022-11-09T03:51:17.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-09T04:40:44.000Z (over 2 years ago)
- Last Synced: 2025-01-20T08:13:05.515Z (5 months ago)
- Language: Python
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Telegram bot: External IP fetcher
_Quick-N-Dirty edition_
This is a simple Telegram bot that will fetch the external IP whenever it receives the `/ip` command.
It was designed to be resilient and keep going even when any errors happen. Is this a good thing? For this use case, yes. (but not always...)
# How to use
## 1: Create a Bot
Follow this tutorial to create a Bot and get the token: https://core.telegram.org/bots/tutorial#obtain-your-bot-token## 2: Get your chat_id
Since the bot will only answer to one person, you must find out your user_id (aka: chat_id)To do that, follow this tutorial: https://www.alphr.com/find-chat-id-telegram/
## 3: Add token + chat_id to main.py
Open file `main.py` and add your data there.
> Attention: Careful not to add your secrets to a public repository. Don't do that, please!Let's say your token is `1a2b3c-4d-5e-6f-7g` and your chat_id is `42`.
In your `main.py` file, the call to main method should be something like this:
```python
main(
token="1a2b3c-4d-5e-6f-7g",
chat_id=42
)
```## 4: Install Python requirements.
This bot requires Python 3.9+ to work and relies on two packages:
1. requests
2. python-telegram-botTo install all dependencies, while in root folder of the project, run the command:
```shell
pip install -r requirements.txt
```## 5: Run the bot!
To start the bot, run the command:
```shell
python main.py
```