From c2c7b60738516a0b4431b248d51a1c0b1505a7b4 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Sun, 1 Jul 2018 15:04:39 +0530 Subject: [PATCH] Add edit_html --- webhook.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/webhook.php b/webhook.php index ee7e4ad..a418894 100644 --- a/webhook.php +++ b/webhook.php @@ -41,6 +41,33 @@ function send_html($post_message, $reply=false) { $result = file_get_contents($url, false, $context); } +// Edits existing pinned message +function edit_html($post_message, $reply=false) { + global $decoded; + global $bot_api; + global $chat_id; + $message_id = require("message.php"); + $url = 'https://api.telegram.org/bot' . $bot_api . '/editMessageText'; + $post_msg = array('chat_id' => $chat_id, 'text' =>$post_message, 'message_id' => $message_id, 'parse_mode' => 'html'); + if ($reply != false) { + if ($reply === true){ + $post_msg['reply_to_message_id'] = $decoded->{'message'}->{'message_id'}; + } + else { + $post_msg['reply_to_message_id'] = $reply; + } + } + $options = array( + 'http' => array( + 'header' => "Content-type: application/x-www-form-urlencoded\r\n", + 'method' => 'POST', + 'content' => http_build_query($post_msg) + ) + ); + $context = stream_context_create($options); + $result = file_get_contents($url, false, $context); +} + function add_requirement() { global $command_list; $item_id = $command_list[1];