Add telegram util to send telegram messages and location
This commit is contained in:
0
src/utils/index.js
Normal file
0
src/utils/index.js
Normal file
19
src/utils/telegram.js
Normal file
19
src/utils/telegram.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import axios from "axios";
|
||||
|
||||
class Telegram {
|
||||
constructor(token) {
|
||||
this.axios = axios.create({
|
||||
baseURL: `https://api.telegram.org/bot${token}`
|
||||
});
|
||||
}
|
||||
|
||||
sendMessage(chat_id, text) {
|
||||
this.axios.post("/sendMessage", {chat_id, text});
|
||||
}
|
||||
|
||||
sendLocation(chat_id, latitude, longitude) {
|
||||
this.axios.post("/sendLocation", {chat_id, latitude, longitude});
|
||||
}
|
||||
}
|
||||
|
||||
export default Telegram;
|
||||
Reference in New Issue
Block a user