-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (29 loc) · 753 Bytes
/
index.js
File metadata and controls
33 lines (29 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
const axios = require('axios')
const token=require('./token.js').token
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.post('/new-message', function(req, res) {
const {message} = req.body
axios.post('https://api.telegram.org/bot'+token+'/sendMessage', {
chat_id: message.chat.id,
text: 'Rathore'
})
.then(response => {
res.end('ok')
})
.catch(err => {
res.end('Error :' + err)
})
});
app.get('/',(req,res)=>{
res.send("its working")
})
// Finally, start our server
app.listen(process.env.PORT||80, function() {
console.log('Telegram app listening on port 3000!');
});