首页 > 解决方案 > 询问如何在 Telegram 中为内联查询创建数组

问题描述

如果我的搜索在电报和电报中是这样的,如何显示视频数据。我也希望视频和文档也可搜索?

bot.on('inline_query',async(ctx)=>{
query = ctx.inlineQuery.query
    if(query.length>0){
        let searchResult = saver.getfileInline(query).then((res)=>{
            let result = res.map((ctx,index)=>{
                return {
                    type:'document',
                    id:ctx._id,
                    title:ctx.file_name,
                    document_file_id:ctx.file_id,
                    caption:ctx.caption,
                    reply_markup:{
                        inline_keyboard:[
                            [{text:"Pencarian",switch_inline_query:''}]
                        ]
                    }
                }
            })
        
            ctx.answerInlineQuery(result)
        })
    }else{
        console.log('query not found');
    }


})

标签: javascriptnode.jsapitelegramtelegraf

解决方案


推荐阅读