trackmyd-bot/README.md

66 lines
2.2 KiB
Markdown
Raw Normal View History

2019-03-04 16:40:53 +01:00
# trackmyd-bot
2019-03-04 17:15:58 +01:00
A telegram bot to track your devices.
2019-03-04 16:40:53 +01:00
2019-03-04 17:03:00 +01:00
<img src="screenshot.png" height="400">
2019-03-04 17:15:58 +01:00
This bot is written in Node.js
2019-03-04 16:40:53 +01:00
## Architecture
**trackmyd-bot** uses the [**trackmyd-api**](https://github.com/frab1t/trackmyd-api) project APIs to get device locations.
To configure the server, refer to the [**trackmyd-api**](https://github.com/frab1t/trackmyd-api) repository.
In order to use trackmyd-bot, in addiction to the configuration of the trackmyd-api, its also necessary to configure [**GPSLogger**](https://github.com/mendhak/gpslogger), an open-source application that allows sending location through HTTP calls.
<img src="architecture.png" height="150">
## Usage
Before requesting the position to the bot you need to add a new device and configure it.
2019-03-04 17:08:13 +01:00
#### Configuration:
2019-03-04 16:40:53 +01:00
1. **Add a new device.**
2019-03-04 17:08:13 +01:00
Send the `/add` command to the bot. You will be prompted to add the device name.
2019-03-04 16:40:53 +01:00
2. **Configure GPSLogger on Android.**
2019-03-04 17:08:13 +01:00
Once confirmed the device name, the bot will return 3 messages:
- URL (full-path including the device ID)
- HEADER (HTTP header, used for authentication to APIs)
- BODY (HTTP body with the parameters that will be automatically evaluated by GPSLogger).
2019-03-04 16:40:53 +01:00
2019-03-04 17:08:13 +01:00
Take the values and insert them in the GPSLogger app under "Logging details > Log to custom URL" specifying method http = 'PATCH'
2019-03-04 16:40:53 +01:00
- Press "Start Logging" on GPSLogger.
3. **Request the position at the bot**
Send the `/position` command to the bot and select the device. If the device (with GPSLogger) has sent the information to the API, 2 messages will be returned (one with the location on the map, and one with additional information).
## Installation
### Step by step
1. Install **NodeJS** and **NPM**.
2. Clone this repository.
3. Install dependencies with `npm install`.
4. Create a new bot with **BotFather** on Telegram
5. Enter the **token** generated by BotFather in (app.token) into `config.json`.
6. Enter your **Telegram ID** in (app.authorizedUsers) into `config.json`.
7. Configure Basic Authentication in (app.api.headers) into `config.json`.
8. Start with `npm start`.
2019-03-04 17:08:13 +01:00
The bot was created for fun.
2019-03-04 16:40:53 +01:00
Made with ❤️ by Francesco Esposito ([@frab1t](https://github.com/frab1t))