Ботман Телеграмма - PullRequest
       8

Ботман Телеграмма

0 голосов
/ 30 октября 2018

они могли бы помочь мне, я не знаю, как поместить кнопки в телеграмме, только в мессенджере facebook, где может быть ошибка?

$ botman-> hears ('1', function ($ bot) { $ bot-> reply ("• Версия Android 4.4.2 (KitKat) o превосходная • Espacio en memoria de almacenamiento • Memoria RAM превосходит 1 ГБ • Duración de batería, превосходящий 12 часов непрерывной работы • Conexión красный celular 3G o превосходный • Conexión Интернет ");

$ bot-> reply ('¿Algo más en lo que que pueda ayudarte?') -> addButton (Button :: create ('Расскажи анекдот') ) -> addButton (Button :: create («Дай мне необычную цитату») )

});

1 Ответ

0 голосов
/ 09 марта 2019

Это решается с помощью классов app / Conversations.php

<?php

namespace App\Conversations;

use Illuminate\Foundation\Inspiring;
use BotMan\BotMan\Messages\Incoming\Answer;
use BotMan\BotMan\Messages\Outgoing\Question;
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
use BotMan\BotMan\Messages\Conversations\Conversation;

class ExampleConversation extends Conversation
{
    /**
     * First question
     */
    public function askReason()
    {
        $question = Question::create("Huh - you woke me up. What do you need?")
            ->fallback('Unable to ask question')
            ->callbackId('ask_reason')
            ->addButtons([
                Button::create('Tell a joke')->value('joke'),
                Button::create('Give me a fancy quote')->value('quote'),
            ]);

        return $this->ask($question, function (Answer $answer) {
            if ($answer->isInteractiveMessageReply()) {
                if ($answer->getValue() === 'joke') {
                    $joke = json_decode(file_get_contents('http://api.icndb.com/jokes/random'));
                    $this->say($joke->value->joke);
                } else {
                    $this->say(Inspiring::quote());
                }
            }
        });
    }
                     //clases dinamicas, cambiar estructura de base de datos  :v
    /**
     * Start the conversation
     */
    public function run()
    {
        $this->askReason();
    }
}

и в вашем botman.php:

$botman->hears('/start', function (BotMan $bot) {
    $bot->startConversation(new ExampleConversation());
});
...