【发布时间】:2021-04-08 15:15:43
【问题描述】:
我正在使用laravel-notification-channels/telegram 我已经为我的用户实现了欢迎通知,并且我的机器人毫无问题地发送了该消息,我实现的第二部分是将这些用户(我已经发送了欢迎消息)添加到我的频道。
PS:我的机器人是我频道的管理员,可以添加用户。
逻辑
- Telegram 用户可以注册(完成)
- 获取电报用户数据并发送欢迎信息(完成)
- 通过机器人将电报用户添加到我的频道。 (需要帮助)
代码
Note:我的代码目前只够发送欢迎信息,没有添加用户到频道...
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
//.....
有什么想法吗?
【问题讨论】:
标签: php laravel telegram telegram-bot php-telegram-bot