Skip to content

Commit 836c3bb

Browse files
authored
Merge pull request #90 from caco3/master
Added Inline Keyboard, converted if's to elseif's
2 parents a99576f + 76b4270 commit 836c3bb

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

bot examples/webhook/update.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@
6363
$content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => $reply);
6464
$telegram->sendMessage($content);
6565
}
66-
if ($text == "/git") {
66+
67+
elseif ($text == "/git") {
6768
$reply = "Check me on GitHub: https://github.com/Eleirbag89/TelegramBotPHP";
6869
// Build the reply array
6970
$content = array('chat_id' => $chat_id, 'text' => $reply);
7071
$telegram->sendMessage($content);
7172
}
7273

73-
if ($text == "/img") {
74+
elseif ($text == "/img") {
7475
// Load a local file to upload. If is already on Telegram's Servers just pass the resource id
7576
$img = curl_file_create('test.png','image/png');
7677
$content = array('chat_id' => $chat_id, 'photo' => $img );
@@ -81,11 +82,25 @@
8182
$telegram->downloadFile($file["result"]["file_path"], "./test_download.png");
8283
}
8384

84-
if ($text == "/where") {
85+
elseif ($text == "/where") {
8586
// Send the Catania's coordinate
8687
$content = array('chat_id' => $chat_id, 'latitude' => "37.5", 'longitude' => "15.1" );
8788
$telegram->sendLocation($content);
8889
}
90+
91+
elseif ($text == "/inlinekeyboard") {
92+
// Shows the Inline Keyboard and Trigger a callback on a button press
93+
$option = array(
94+
array(
95+
$telegram->buildInlineKeyBoardButton("Callback 1", $url="", $callback_data="1"),
96+
$telegram->buildInlineKeyBoardButton("Callback 2", $url="", $callback_data="2")
97+
)
98+
);
99+
100+
$keyb = $telegram->buildInlineKeyBoard($option);
101+
$content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "This is an InlineKeyboard Test with Callbacks");
102+
$telegram->sendMessage($content);
103+
}
89104
}
90105

91106
?>

0 commit comments

Comments
 (0)