the bot will give the right answer or greeting automatically when new user join the chatroom
N/A
Need to learn how
Is there a guide or sample for this using message -> new_chat_member command. This way hook.php will notice when a new chat members join the room
Take a look at this: https://github.com/php-telegram-bot/example-bot/blob/master/Commands/NewchatmembersCommand.php, it does exactly what you want I guess.
@jacklul yes I examine the code, however I'm not sure how to activated this command. What need to be written on hook.php so it will run it when new user join the chatroom. Any help will be greatly appriciated
@jacklul did the hook.php and it work for most command. However automatically do a greeting for a new chat user is not being called.
Did you tried copying that NewchatmembersCommand.php from example-bot repository into your project's commands dir?
@ranrinc You have downloaded the example NewchatmembersCommand from the example-bot repository, right?
edit: GitHub just refreshed and I saw that @jacklul beat me to it :+1:
@noplanman off course.. its already in command folder.
Just to make sure: is your 'latest' library version at least 0.45.0 ?
@jacklul its the latest library.. just wondering if I need to embeded specific code line on hook.php? Something that automatically trigger when new user join the chat?
It should be triggered automatically if custom command path is pointing to folder where mentioned command class is.
@ranrinc Did you get this to work now?
@noplanman unfortunately no...:(
Could you post your NewchatmembersCommand.php file?
If you have it in a folder that gets added as a custom commands path, then there must be a problem in that file 馃
```` /**
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Request;
/**
/**
* @var string
*/
protected $description = 'New Chat Members';
/**
* @var string
*/
protected $version = '1.2.0';
/**
* Command execute method
*
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$members = $message->getNewChatMembers();
$text = 'Hi there!';
if (!$message->botAddedInChat()) {
$member_names = [];
foreach ($members as $member) {
$member_names[] = $member->tryMention();
}
$text = 'Hi ' . implode(', ', $member_names) . '!';
}
$data = [
'chat_id' => $chat_id,
'text' => $text,
];
return Request::sendMessage($data);
}
}
````
@noplanman I did not made any changes
Ok, that's strange then.
Could you get in touch on Telegram please? My username is noplanman
Have you found the problem or is it still not working?
This issue still exists now,It's still not working.
I am trying figure it out.
This issue has been resolved in NewChatMembers Command not working #1108 .