I deploy my project on heroku using express+request.I can reply text,but failed to reply with markup.I've been working on this proble for almost 2 days,but I can't fix it.
app.post("/",async(req,final)=>{
const body=req.body
console.log(JSON.stringify(body))
if(body.message){
const form={
text:req.body.message.text,
msgid:req.body.message.message_id,
uid:req.body.message.from.id,
chatid:req.body.message.chat.id
}
if(form.text.indexOf("/start")!=-1){
sendMessage(form.chatid,form.msgid,"Welcome")
}else{
let reply_markup={}
reply_markup.inline_keyboard=[]
let inlineRow=[]
inlineRow.push({
text:"one",
callback_data:"/one:"+body.message.text
})
inlineRow.push({
text:"two",
callback_data:"/two:"+body.message.text
})
let inlineRow1=[]
inlineRow1.push({
text:"three",
callback_data:"/three:"+body.message.text
})
inlineRow1.push({
text:"four",
callback_data:"/four:"+body.message.text
})
reply_markup.inline_keyboard.push(inlineRow)
reply_markup.inline_keyboard.push(inlineRow1)
sendMsgButton(form.chatid,"Click a button",reply_markup)
}
}
final.send("SUCCESS")
})
function sendMsgButton(chat_id,text,reply_markup){
request({
url:"https://api.telegram.org/botAPITOken/",
method:"POST",
form:{
"method": "sendMessage",
"chat_id": chat_id,
"parse_mode":"Markdown",
"reply_markup":reply_markup,
"text":text
}
},(err,res,body)=>{
console.log("SendMessage",body)
})
}
Someone knows what's wrong with my code? Please help me/(ㄒoㄒ)/~~