doupin1073 2018-03-11 17:26
浏览 95

Telegram Bot内联反馈不会返回任何更新

i enable /setinlinefeedback (100% for test) in Botfather and my answerInlineQuery show correct results with no error {"ok":true,"result":true}... but when tap on one of the results return no update and when i send the update to chat, update return

{"update_id":14516733, "message":{"message_id":1857,"from{"id":96000969,"is_bot":false,"first_name":"Mostafa","last_name":"Emrani","username":"Mostafa_MRNI","language_code":"en-US"},"chat":{"id":96000969,"first_name":"Mostafa","last_name":"Emrani","username":"Mostafa_MRNI","type":"private"},"date":1520788397,"text":"Your Product:"}}

update if (isset($update->chosen_inline_result->result_id)) return false.

my answerInlineQuery functions:

if (isset($update->inline_query)) {

        $inlineQuery = $update->inline_query;
        $queryId = $inlineQuery->id;
        $userId = $inlineQuery->from->id;
        $Chatid = $this->model->getChatIdformUser($userId);
        $queryText = $inlineQuery->query;

        //$this->model->sendMessage($Chatid, $queryId . '-' . $userId . '-' . $Chatid . '-' . json_encode($inlineQuery, JSON_UNESCAPED_UNICODE));

        if ($queryText == '#invoice') {
            $resu = $this->model->answerInlineQuery($queryId, $this->queryResultsInvoice($Chatid), 0, true);
        } else {
            $resu = $this->model->answerInlineQuery($queryId, $this->queryResults($queryText), 0, false);
        }
        //$this->model->sendMessage($Chatid, json_encode($resu));
    }

and

function answerInlineQuery($inline_query_id, $results, $cache_time , $is_personal)
{

    $url = 'https://api.telegram.org/bot' . BOT_API_KEY . '/answerInlineQuery';

    $post = array("inline_query_id" => $inline_query_id, "results" => json_encode($results), "cache_time" => $cache_time, "is_personal" => $is_personal);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 500);

    $check = curl_exec($ch);
    curl_close($ch);
    //$this->sendMessage($chatid,$check);
    return $check;
}

and

   function queryResults($qryText)
{
    $res = $this->model->inlineSearch($qryText);
    $result = array();
    for ($x = 1; $x <= sizeof($res); $x++) {
        $result1 = array('type' => 'article', 'id' => strval($res[$x - 1]['prod_code']), 'title' => $res[$x - 1]['prod_name'], 'input_message_content' => array('message_text' => 'Your Product:'), 'description' => $res[$x - 1]['prod_price'] . ' $ ');
        array_push($result, $result1);
    }
    return $result;
}

function queryResultsInvoice($Chatid)
{
    $res = $this->model->getProductInOrder($Chatid);
    $result = array();
    for ($x = 1; $x <= sizeof($res); $x++) {
        $res_prodCount = $this->model->getCountProd($Chatid, $res[$x - 1]['prod_id']);
        $desc = '';
        if ($res_prodCount != 0) {
            $desc = '-- In your order ' . $res_prodCount . 'has available.';
        }
        $result1 = array('type' => 'article', 'id' => strval($res[$x - 1]['prod_code']), 'title' => $res[$x - 1]['prod_name'], 'input_message_content' => array('message_text' => 'Your Product:'), 'description' => $res[$x - 1]['prod_price'] . ' $ ' . $desc);
        array_push($result, $result1);
    }
    return $result;
}

when i getWebhookInfo return no error... please help me... i spend 5 days in this problem and have no idea to solve it...

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大