const{Telegraf}=require("telegraf");constaxios=require("axios");constbot=newTelegraf("XXXXX");bot.start((ctx)=>ctx.reply("Welcome"));bot.help((ctx)=>ctx.reply("Send me a sticker"));bot.on("sticker",(ctx)=>ctx.reply("👍"));bot.hears("hi",(ctx)=>ctx.reply("Hey there"));bot.hears("Wow",async(ctx)=>{letstateNames=awaitgetStates();console.log(stateNames);letlistt=[];for(letindex=0;index<stateNames.length-1;index+=2){listt.push([{text:stateNames[index],callback_data:String(index)},{text:stateNames[index+1],callback_data:String(index+1)},]);}console.log(listt);ctx.telegram.sendMessage(ctx.chat.id,"nani",{reply_markup:{inline_keyboard:listt,},});});bot.launch();// Enable graceful stopprocess.once("SIGINT",()=>bot.stop("SIGINT"));process.once("SIGTERM",()=>bot.stop("SIGTERM"));asyncfunctiongetStates(){url="https://api.covid19india.org/data.json";res=awaitaxios.get(url);stateArr=res.data.statewise;totalStates=stateArr.length;letstateName=newArray();for(leti=0;i<totalStates;i++){stateName[i]=stateArr[i].state;}// console.log(stateName);returnstateName;}
can you specify the issue ?
So basically I have an array i want to show elements from an array in inlineKeyboard buttons
I have explained it on stackoverflow:
stackoverflow.com/questions/676461...
Pls help
I'll take a look , and let you know .
Yes please
hope this helps
Thank you so much, sir. I have been stuck for one week on this issue. Thank you so much for resolving and providing a solution.
I tried myself but couldn't solve it. I googled it, asked so many peoples but no one replied, and finally, you solved it.
Again Thank you so much.
your welcome ✌