Integrate telegram with accident plugin
This commit is contained in:
parent
b743cbc9a5
commit
facd8d912f
|
@ -3,7 +3,17 @@ import PropTypes from "prop-types";
|
|||
import { Box, Button, Heading, Text } from "grommet";
|
||||
import { Aid, Impact } from "grommet-icons";
|
||||
|
||||
import Telegram from "../utils/telegram";
|
||||
import { TG_API, TG_USERID } from "../config";
|
||||
|
||||
function sendNotification(close) {
|
||||
const bot = new Telegram(TG_API);
|
||||
bot.sendMessage(TG_USERID, "User detected in an accident. Location has been attached below.");
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
position => bot.sendLocation( TG_USERID,
|
||||
position.coords.latitude, position.coords.longitude),
|
||||
() => bot.sendMessage(TG_USERID, "Error retrieving location")
|
||||
);
|
||||
setTimeout(close, 2000);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const WS_BASE = "http://localhost:5050/";
|
||||
const TG_API = "xxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxx";
|
||||
const TG_USERID = 123456789;
|
||||
|
||||
export { WS_BASE };
|
||||
export { WS_BASE, TG_API, TG_USERID };
|
||||
|
|
Loading…
Reference in New Issue