Basic response filtering
This commit is contained in:
22
scripts/makeResponse.js
Normal file
22
scripts/makeResponse.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// Make a response e
|
||||
|
||||
//Check if can be responded to
|
||||
exports.canRespond = msg=>{
|
||||
//let words = msg.split(" ")
|
||||
return('!'==msg[0])
|
||||
}
|
||||
|
||||
exports.getCommand = msg=>{
|
||||
let words = msg.split(" ")
|
||||
return words[0].substring(1)
|
||||
}
|
||||
|
||||
exports.getPredicate = msg=>{
|
||||
let pred = msg.split(" ")
|
||||
pred.shift();
|
||||
return pred.join(" ")
|
||||
}
|
||||
|
||||
exports.magnet = searchterm=>{
|
||||
|
||||
}
|
@@ -1,10 +1,18 @@
|
||||
// Obtain a sendMessage Object
|
||||
const makeResponse = require('./makeResponse')
|
||||
|
||||
module.exports = (updateObject)=>{
|
||||
module.exports = (messageObject)=>{
|
||||
if(makeResponse.canRespond(messageObject.text)){
|
||||
console.log(makeResponse.getCommand(messageObject.text))
|
||||
return {
|
||||
"chat_id": updateObject.from.id,
|
||||
"text":updateObject.text,
|
||||
"reply_to_message_id": updateObject.message_id
|
||||
"chat_id": messageObject.from.id,
|
||||
"text": makeResponse.getPredicate(messageObject.text),
|
||||
"parse_mode": "Markdown",
|
||||
"reply_to_message_id": messageObject.message_id
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
return null
|
||||
}
|
||||
//return JSON.stringify(updateObject)
|
||||
}
|
@@ -7,6 +7,8 @@ module.exports.call = (base,updateObject)=>{
|
||||
if('message' in updateObject){
|
||||
let responseObject = process(updateObject.message)
|
||||
//console.log(process.process(updateObject.message))
|
||||
if(responseObject)
|
||||
{
|
||||
request.post({
|
||||
"url":`${base}sendMessage`,
|
||||
"json":true,
|
||||
@@ -16,4 +18,5 @@ module.exports.call = (base,updateObject)=>{
|
||||
if(body.ok) console.log("Successfully sent")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user