2

using the below code sniplet to send an InlineQuery to a chat (or channel or group) in Telegram as answer to a "Share"-button from another chat - it seems to work well...

My inline bot creates a message and places it into the target chat.

Problem is: I do not get a message-ID or similar back which allows me to acces this message again in order to be able to modify it.

(Goal is to synchronize content between several channels even if no bot is part of the the channel and the content has been shared via "Share"-inline-buttons).

I.e. $res in the sample below is $res = {"ok":true,"result":true}

Any idea, what can be done?!

Thanks!

$botID = 'botabcdefghij1234567890';
$url = "https://api.telegram.org/$botID/answerInlineQuery";

$results = array(
    array(
        "type" => "article",
        "id" => $iid,
        "title" => $title,
        "description" => $desc,    
        "reply_markup" => $reply,  // some buttons here
        "input_message_content" => array(
            "message_text" => "$txt",   // synchronized text
            "parse_mode" => "HTML"
        )
    )
);

$post = array("inline_query_id" => $iid, "results" => json_encode($results));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$res = curl_exec($ch);
curl_close($ch);
Gerrit
  • 21
  • 2

1 Answers1

1

You can send multiple answers in one inline query, so please enable /setinlinefeedback in @BotFather to receive messages ID.

It will return chosen_inline_result update, then use inline_message_id to modify the message.

Sean Wei
  • 7,433
  • 1
  • 19
  • 39
  • I guess, this is the wrong "side" of the information. Data flow is as follows: Main channel: Message with infos and buttons popping up (incl "Share" button). When pressing "Share", inline bot will place the Message box within the target channel (without getting any information about this channel or this message back!). When clicking anything in the target channel, I get inline_message_id (or so) back and can modify THAT message. But I cannot modify it from "outside" as I do not have any information in my bot where the message was placed, right?! Or not?! Thanks again – Gerrit Jan 03 '18 at 23:08