telegram icon indicating copy to clipboard operation
telegram copied to clipboard

Call to a member function toNotGiven() on not TelegramSenderContract

Open Samoylenko666 opened this issue 1 year ago • 0 comments

This pull request allows us not to send notifications if we do not return TelegramSenderContract.

In some cases I no longer need to send a notification. The most common case is that the time for sending the notification has already expired. I would like to be able to return a type that does not implement the TelegramSenderContract functionality. Look at the following code

public function toTelegram($notifiable): TelegramMessage|false
 {
        if (do not send notification)
        {
            return false;
        }

        // Send notification
        return TelegramMessage::create()
            ->to(config('services.telegram-bot-api.chat_id'))
            ->line('hello');
      
}

This code return error local.ERROR: Call to a member function toNotGiven() on false {"exception":"[object] (Error(code: 0): Call to a member function toNotGiven() on false at /var/www/html/vendor/laravel-notification-channels/telegram/src/TelegramChannel.php:41)

Samoylenko666 avatar Jun 14 '24 07:06 Samoylenko666