Implement basic replies
This commit is contained in:
3
index.js
3
index.js
@@ -36,7 +36,6 @@ setInterval(()=>{
|
||||
}
|
||||
// contents - Now work on response
|
||||
if(contents.result.length>0){
|
||||
//console.log(`Update:${JSON.stringify(contents.result)}`)
|
||||
// Ready to work on
|
||||
if(parameters.offset===null){
|
||||
parameters.offset = contents.result[0].update_id + 1
|
||||
@@ -47,7 +46,7 @@ setInterval(()=>{
|
||||
parameters.offset = e.update_id + 1
|
||||
}
|
||||
//console.log(e.update_id)
|
||||
respond.call(e)
|
||||
respond.call(base,e)
|
||||
})
|
||||
|
||||
|
||||
|
@@ -1,3 +1,10 @@
|
||||
module.exports.process = (updateObject)=>{
|
||||
return updateObject.message.text
|
||||
// Obtain a sendMessage Object
|
||||
|
||||
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){
|
||||
console.log(updateObject.message.text)
|
||||
//console.log("New Message")
|
||||
let responseObject = process(updateObject.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