From a973357d53c5524cea8f134ae0c93f9d97dc4235 Mon Sep 17 00:00:00 2001 From: hms5232 Date: Mon, 12 Feb 2024 15:34:19 +0800 Subject: [PATCH] docs: introduce project and how to use --- .env.example | 2 ++ README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..9139919 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +TOKEN = '' # replace with bot token +NOTIFY_USER_ID = '' # replace with user/group id which will receive message diff --git a/README.md b/README.md index 61a9821..c5c4414 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,53 @@ # get-LAN-IP-telegram-bot-rs -The Rust version of get-LAN-IP-telegram-bot +The Rust version of [get-LAN-IP-telegram-bot](https://github.com/hms5232/get-LAN-IP-telegram-bot). + +## Background + +The original project is developed for Raspberry Pi. This saves me much time from IP checking. + +But, I'm not sure why the Python virtual environment can't get IP when RPi just booted. I resolved it with a stupid way: delay. + +This actually work. However, I need to keep waiting even device had booted until message delivered. + +Now, I migrate this project to Rust, and it seems more fast and reliable in my case. + +## Usage + +### Config + +You can use environment variables or dotenv. + +#### Environment + +```shell +export TOKEN='bot token' +export NOTIFY_USER_ID='chat id' +``` + +#### dotenv + +```shell +cp .env.example .env +``` + +then replace value for your bot and chat/user id. + +※ The `.env` file should be placed same or parent dir with executable binary file. + +### Run on RPi + +Add the following line into `/etc/rc.local`: + +```shell +(cd /path/to/binary && ./get-LAN-IP-telegram-bot-rs; cd -)& +``` + +for example: + +```shell +(cd /home/pi/Documents/get-LAN-IP-telegram-bot-rs && ./target/release/get-LAN-IP-telegram-bot-rs; cd -)& +``` + +## LICENSE + +[MPL 2.0](LICENSE)