I am using laravel-notification-channels/telegram I've implemented welcome notification for my users and my bot sending that message with no issue, the second part of my implementation is to add those users (who I've sent welcome message) into my channel.
PS:
My bot is admin of my channel and has access to add users.
Logic
- Telegram users can register (done)
- Get telegram users data and send welcome message (done)
- Add telegram users to my channel by bot. (need help)
Code
Note:
my code currently is just enough to send welcome message, nothing about adding users to channel...
public $user;
public $telegram_id;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($user, $telegram_id)
{
$this->user = $user;
$this->telegram_id = $telegram_id;
}
public function toTelegram($notifiable)
{
// first message to bot (to recognize the user)
TelegramMessage::create()
->to('MY_BOT_ID');
// then message the user from bot
return TelegramFile::create()
->to($this->telegram_id) // registered user ID on telegram
->content("Hello");
}
// (NEXT) add user to channel
//.....
Any idea?