Integrate telegram with accident plugin

This commit is contained in:
Ceda EI 2021-01-01 15:58:29 +05:30
parent b743cbc9a5
commit facd8d912f
2 changed files with 13 additions and 1 deletions

View File

@ -3,7 +3,17 @@ import PropTypes from "prop-types";
import { Box, Button, Heading, Text } from "grommet"; import { Box, Button, Heading, Text } from "grommet";
import { Aid, Impact } from "grommet-icons"; import { Aid, Impact } from "grommet-icons";
import Telegram from "../utils/telegram";
import { TG_API, TG_USERID } from "../config";
function sendNotification(close) { 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); setTimeout(close, 2000);
} }

View File

@ -1,3 +1,5 @@
const WS_BASE = "http://localhost:5050/"; 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 };