Implement basic replies
This commit is contained in:
3
index.js
3
index.js
@@ -36,7 +36,6 @@ setInterval(()=>{
|
|||||||
}
|
}
|
||||||
// contents - Now work on response
|
// contents - Now work on response
|
||||||
if(contents.result.length>0){
|
if(contents.result.length>0){
|
||||||
//console.log(`Update:${JSON.stringify(contents.result)}`)
|
|
||||||
// Ready to work on
|
// Ready to work on
|
||||||
if(parameters.offset===null){
|
if(parameters.offset===null){
|
||||||
parameters.offset = contents.result[0].update_id + 1
|
parameters.offset = contents.result[0].update_id + 1
|
||||||
@@ -47,7 +46,7 @@ setInterval(()=>{
|
|||||||
parameters.offset = e.update_id + 1
|
parameters.offset = e.update_id + 1
|
||||||
}
|
}
|
||||||
//console.log(e.update_id)
|
//console.log(e.update_id)
|
||||||
respond.call(e)
|
respond.call(base,e)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,3 +1,10 @@
|
|||||||
module.exports.process = (updateObject)=>{
|
// Obtain a sendMessage Object
|
||||||
return updateObject.message.text
|
|
||||||
|
module.exports = (updateObject)=>{
|
||||||
|
return {
|
||||||
|
"chat_id": updateObject.from.id,
|
||||||
|
"text":updateObject.text,
|
||||||
|
"reply_to_message_id": updateObject.message_id
|
||||||
|
}
|
||||||
|
//return JSON.stringify(updateObject)
|
||||||
}
|
}
|
@@ -1,6 +1,19 @@
|
|||||||
module.exports.call = (updateObject)=>{
|
// Send update object for processing and request to send reply
|
||||||
|
|
||||||
|
const process = require('./process')
|
||||||
|
const request = require('request')
|
||||||
|
|
||||||
|
module.exports.call = (base,updateObject)=>{
|
||||||
if('message' in updateObject){
|
if('message' in updateObject){
|
||||||
console.log(updateObject.message.text)
|
let responseObject = process(updateObject.message)
|
||||||
//console.log("New Message")
|
//console.log(process.process(updateObject.message))
|
||||||
|
request.post({
|
||||||
|
"url":`${base}sendMessage`,
|
||||||
|
"json":true,
|
||||||
|
"body":responseObject
|
||||||
|
},(err,res,body)=>{
|
||||||
|
if(err) console.log(err)
|
||||||
|
if(body.ok) console.log("Successfully sent")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user