Longman\TelegramBot\Commands\AdminCommands\SendtochannelCommand::publish PHP Méthode

publish() protected méthode

Publish a message to a channel and return success or failure message
protected publish ( Message $message, integer $channel, string | null $caption = null ) : string
$message Longman\TelegramBot\Entities\Message
$channel integer
$caption string | null
Résultat string
    protected function publish(Message $message, $channel, $caption = null)
    {
        $data = ['chat_id' => $channel, 'caption' => $caption];
        if ($this->sendBack($message, $data)->isOk()) {
            $response = 'Message sent successfully to: ' . $channel;
        } else {
            $response = 'Message not sent to: ' . $channel . PHP_EOL . '- Does the channel exist?' . PHP_EOL . '- Is the bot an admin of the channel?';
        }
        return $response;
    }