Add a quick example of how the button junk works
authorCameron Ball <cameron@moodle.com>
Thu, 9 May 2019 06:01:32 +0000 (14:01 +0800)
committerCameron Ball <cameron@moodle.com>
Thu, 9 May 2019 07:03:07 +0000 (15:03 +0800)
src/gnb.php

index c139a87..24648eb 100644 (file)
@@ -13,6 +13,26 @@ if(getTelegram()->getWebHookUpdates()->get('message') && !canChatWith(getTelegra
     exit(0);
 }
 
+if (getTelegram()->getWebHookUpdates()->detectType() == 'callback_query') {
+    $cbq = getTelegram()->getWebHookUpdates()->getCallbackQuery();
+    // handling for paginating shit
+    $data = $cbq->getData(); // that's gonna have the data attached to the button
+    if ($data) {
+        $keyboard = [
+            'inline_keyboard' => [[['text' =>  $data == 'jeff' ? 'chef' : 'jeff', 'callback_data' => $data == 'jeff' ? 'chef' : 'jeff']]],
+        ];
+
+        $markup = json_encode($keyboard);
+
+        getTelegram()->editMessageText([
+            'chat_id' => getTelegram()->getWebHookUpdates()->getChat()->getId(),
+            'message_id' => $cbq->getMessage()->getMessageId(),
+            'text' => 'my name is ' . $data,
+            'reply_markup' => $markup
+        ]);
+    }
+}
+
 getTelegram()->addCommand(
     new class extends Command {
         protected $name = 'digest';