博特曼的电报事件没有发生

时间:2017-12-15 13:51:28

标签: php laravel bots

我正在尝试欢迎群组中的用户,我在handle()方法中有以下代码 -

public function handle(Request $request)
{
    $botman = app('botman');

    $botman->on('new_chat_members', function($payload, $bot) {
        $bot->reply($payload);
    });

    $botman->hears('/help', function ($bot) {

        $result = '/hi - hello';

        $bot->reply($result,  [
            'parse_mode' => 'Markdown'
        ]);
    });

    $botman->fallback(function ($bot) {
        $bot->reply("Sorry, I did not understand these commands. Try: /help");
    });

    $botman->listen();
}

但如果我将任何人添加到该组中,我什么都看不到。我在这里错过了什么吗?

1 个答案:

答案 0 :(得分:0)

我发现了问题。这一行$bot->reply($payload);就是问题所在。我是PHP,Laravel和Botman的新手。我想,它无法将对象作为回复发送。一旦用

替换它

$bot->reply($payload[0]['first_name']);

它奏效了。我至少可以看到加入该组的用户的名字。