博特曼电报

时间:2018-10-30 20:02:19

标签: bots telegram-bot

他们可以帮助我,我不知道如何将按钮放在电报中,仅在Facebook Messenger中,错误可能在哪里?

$ botman-> hears('1',function($ bot){   $ bot-> reply(“•Android版本4.4.2(KitKat)或更高版本 •西班牙语世界 •卓越的Memoria RAM 1 GB •Duracióndebatería优胜者连续12小时 •Conexión上等的红色3G •ConexiónInternet”);

$ bot-> reply(''Algomásen lo que pueda ayudarte?') -> addButton(Button :: create('开个玩笑') ) -> addButton(Button :: create('给我一个漂亮的报价') )

});

1 个答案:

答案 0 :(得分:0)

这是使用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());
});