Reputation: 25
I'm trying to welcome users on the group, I have following code in my handle() method -
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();
}
But I dont see anything if I add anyone to the group. Am I missing anything here?
Upvotes: 0
Views: 720
Reputation: 25
I found the problem. This line $bot->reply($payload);
was the problem. I'm new to PHP, Laravel and Botman. I think, it could not send the object as reply. Once replaced it with
$bot->reply($payload[0]['first_name']);
it worked. I could at least see first name of the user who join the group.
Upvotes: 1