mirror of
https://github.com/franjsco/trackmyd-bot
synced 2025-02-17 20:10:43 +01:00
update dirs/readme
This commit is contained in:
parent
edff30e6c7
commit
e0328d2677
87
README.md
87
README.md
@ -1,33 +1,59 @@
|
|||||||
# trackmyd-bot
|
<h1 align="center">Welcome to trackmyd-bot 🗺️</h1>
|
||||||
|
<p>
|
||||||
|
<a href="https://github.com/franjsco/trackmyd-bot/graphs/commit-activity" target="_blank">
|
||||||
|
<img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" />
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/franjsco/trackmyd-bot/blob/master/LICENSE" target="_blank">
|
||||||
|
<img alt="License: GPL--3.0--or--later" src="https://img.shields.io/github/license/franjsco/trackmyd-bot" />
|
||||||
|
</a>
|
||||||
|
<a href="https://twitter.com/franjsco" target="_blank">
|
||||||
|
<img alt="Twitter: franjsco" src="https://img.shields.io/twitter/follow/franjsco.svg?style=social" />
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
A telegram bot to track your devices.
|
> A telegram bot to track your devices.
|
||||||
|
|
||||||
<img src="screenshot.png" height="400">
|
|
||||||
|
|
||||||
This bot is written in Node.js
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
**trackmyd-bot** uses the [**trackmyd-api**](https://github.com/franjsco/trackmyd-api) project APIs to get device locations.
|
|
||||||
|
|
||||||
To configure the server, refer to the [**trackmyd-api**](https://github.com/franjsco/trackmyd-api) repository.
|
|
||||||
|
|
||||||
|
|
||||||
In order to use trackmyd-bot, in addiction to the configuration of the trackmyd-api, it’s also necessary to configure [**GPSLogger**](https://github.com/mendhak/gpslogger), an open-source application that allows sending location through HTTP calls.
|
![trackmyd screenshot](screenshot.png)
|
||||||
|
|
||||||
|
|
||||||
<img src="architecture.png" height="150">
|
## Install
|
||||||
|
|
||||||
|
|
||||||
|
Steps:
|
||||||
|
1. Install **Node.js** 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. Configure API endpoint(*).
|
||||||
|
|
||||||
|
### Architecture
|
||||||
|
(*) **trackmyd-bot** uses the [**trackmyd-api**](https://github.com/franjsco/trackmyd-api) project APIs to get device locations.
|
||||||
|
|
||||||
|
To configure the server API, refer to the [**trackmyd-api**](https://github.com/franjsco/trackmyd-api) repository.
|
||||||
|
|
||||||
|
In order to use trackmyd-bot, in addiction to the configuration of the trackmyd-api, it’s also necessary to configure [**GPSLogger**](https://github.com/mendhak/gpslogger).
|
||||||
|
|
||||||
|
|
||||||
|
<img align="center" src="architecture.jpg" height="200px">
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
Start server:
|
||||||
|
```sh
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
|
|
||||||
|
### Steps
|
||||||
Before requesting the position to the bot you need to add a new device and configure it.
|
Before requesting the position to the bot you need to add a new device and configure it.
|
||||||
|
|
||||||
1. **Add a new device.**
|
1. **Add a new device (on Bot).**
|
||||||
|
|
||||||
Send the `/add` command to the bot. You will be prompted to add the device name.
|
Send the `/add` command to the bot. You will be prompted to add the device name.
|
||||||
|
|
||||||
2. **Configure GPSLogger on Android.**
|
2. **Configure GPSLogger (on Android).**
|
||||||
|
|
||||||
Once confirmed the device name, the bot will return 3 messages:
|
Once confirmed the device name, the bot will return 3 messages:
|
||||||
|
|
||||||
@ -39,27 +65,26 @@ Before requesting the position to the bot you need to add a new device and confi
|
|||||||
|
|
||||||
Then press "Start Logging" on GPSLogger.
|
Then press "Start Logging" on GPSLogger.
|
||||||
|
|
||||||
3. **Request the position at the bot**
|
3. **Request the position (on 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).
|
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).
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
## Installation
|
👤 **franjsco (Francesco Esposito)**
|
||||||
|
|
||||||
### Step by step
|
* Website: https://franjsco.github.io/
|
||||||
|
* Twitter: [@franjsco](https://twitter.com/franjsco)
|
||||||
|
* Github: [@franjsco](https://github.com/franjsco)
|
||||||
|
|
||||||
1. Install **NodeJS** and **NPM**.
|
## Show your support
|
||||||
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`.
|
|
||||||
|
|
||||||
### License
|
Give a ⭐️ if this project helped you!
|
||||||
|
|
||||||
GPLv3
|
## 📝 License
|
||||||
|
|
||||||
---
|
Copyright © 2020 [franjsco (Francesco Esposito)](https://github.com/franjsco).<br />
|
||||||
Made with ❤️ by Francesco Esposito ([@franjsco](https://github.com/franjsco))
|
This project is [GPL--3.0--or--later](https://github.com/franjsco/trackmyd-bot/blob/master/LICENSE) licensed.
|
||||||
|
|
||||||
|
***
|
||||||
|
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_
|
BIN
architecture.jpg
Normal file
BIN
architecture.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 63 KiB |
618
package-lock.json
generated
618
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@ -1,19 +1,20 @@
|
|||||||
{
|
{
|
||||||
"name": "trackmyd-bot",
|
"name": "trackmyd-bot",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "trackmyd telegram bot",
|
"description": "A telegram bot to track your devices.",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bunyan": "^1.8.12",
|
"bunyan": "^1.8.12",
|
||||||
"node-fetch": "^2.3.0",
|
"node-fetch": "^2.6.0",
|
||||||
"telebot": "^1.2.6"
|
"telebot": "^1.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^5.14.1",
|
"eslint": "^5.16.0",
|
||||||
"eslint-config-airbnb-base": "^13.1.0",
|
"eslint-config-airbnb-base": "^13.2.0",
|
||||||
"eslint-plugin-import": "^2.16.0"
|
"eslint-plugin-import": "^2.20.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"start": "node src/server.js",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
|
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
Before Width: | Height: | Size: 739 KiB After Width: | Height: | Size: 472 KiB |
@ -1,5 +1,5 @@
|
|||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
const { api } = require('./config');
|
const { api } = require('../config.json');
|
||||||
const logger = require('./logger');
|
const logger = require('./logger');
|
||||||
|
|
||||||
const devicesPath = `${api.baseURL}${api.paths.devices}`;
|
const devicesPath = `${api.baseURL}${api.paths.devices}`;
|
@ -1,4 +1,4 @@
|
|||||||
const config = require('./config');
|
const config = require('../config.json');
|
||||||
|
|
||||||
function auth(userId) {
|
function auth(userId) {
|
||||||
return config.app.authorizedUsers.includes(userId);
|
return config.app.authorizedUsers.includes(userId);
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
const bunyan = require('bunyan');
|
const bunyan = require('bunyan');
|
||||||
const config = require('./config.json');
|
const config = require('../config.json');
|
||||||
|
|
||||||
const log = bunyan.createLogger({
|
const log = bunyan.createLogger({
|
||||||
name: config.app.name,
|
name: config.app.name,
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable consistent-return */
|
/* eslint-disable consistent-return */
|
||||||
const Telebot = require('telebot');
|
const Telebot = require('telebot');
|
||||||
const config = require('./config');
|
const config = require('../config');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const auth = require('./auth');
|
const auth = require('./auth');
|
||||||
const api = require('./api');
|
const api = require('./api');
|
||||||
@ -17,6 +17,8 @@ const bot = new Telebot({
|
|||||||
|
|
||||||
bot.on('/start', (msg) => {
|
bot.on('/start', (msg) => {
|
||||||
if (!auth(msg.from.id)) {
|
if (!auth(msg.from.id)) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`USER ID: ${msg.from.id}`);
|
||||||
return bot.sendMessage(msg.from.id, templates.unauthorizedUser(), { parseMode: 'Markdown' });
|
return bot.sendMessage(msg.from.id, templates.unauthorizedUser(), { parseMode: 'Markdown' });
|
||||||
}
|
}
|
||||||
bot.sendMessage(msg.from.id, templates.welcome(), { parseMode: 'Markdown' });
|
bot.sendMessage(msg.from.id, templates.welcome(), { parseMode: 'Markdown' });
|
||||||
@ -118,6 +120,7 @@ bot.on('ask.removeDevice', (msg) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
bot.start();
|
bot.start();
|
||||||
|
|
||||||
process.on('SIGINT', () => {
|
process.on('SIGINT', () => {
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable no-underscore-dangle */
|
/* eslint-disable no-underscore-dangle */
|
||||||
const config = require('./config');
|
const config = require('../config');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user