joecampo/laravel-notification-basecamp

将通知发布到Basecamp 3的营火

5.0.0 2024-08-20 21:56 UTC

This package is auto-updated.

Last update: 2024-09-20 22:07:27 UTC


README

Basecamp 3聊天机器人营火通知通道,适用于Laravel。

Latest Version on Packagist Software License Build Status Total Downloads

安装

您可以通过composer安装此包

composer require joecampo/laravel-notification-basecamp

使用方法

在Laravel通知中,您现在可以使用它作为via()的通道

use Illuminate\Notifications\Notification;
use NotificationChannels\Basecamp\CampfireChannel;
use NotificationChannels\Basecamp\CampfireMessage;


class ReviewCreated extends Notification
{
    public function via($notifiable)
    {
        return [CampfireChannel::class];
    }

    public function toCampfire($notifiable)
    {
        return CampfireMessage::create()->data('Hello from my chatbot 🤖');
    }
}

您需要在您的可通知模型中实现一个routeNotificationForBasecamp方法,该方法返回Basecamp 3为您的聊天机器人提供的webhook URL。(设置Basecamp 3聊天机器人

    public function routeNotificationForBasecamp()
    {
        return 'https://basecamp3.lvh.me';
    }

消息

Basecamp允许聊天机器人发布以下标签:table tr td th thead tbody details summary。您可以在富文本内容中使用以下标准HTML标签:divh1brstrongemstrikea(带有href属性)、preolulliblockquote

此包提供用于简单消息和详细信息/摘要消息的辅助函数。

简单消息

 CampfireMessage::create()->data("It Doesn't Have To Be Crazy At Work");

摘要加详细信息

摘要将显示,除非点击,否则详细信息将被隐藏。这对于显示可能具有长堆栈跟踪等的信息非常有用。

CampfireMessage::create()
  ->summary('This is the text/markup used as the summary')
  ->details('This is the text/markup that is hidden unless clicked on in the UI');

测试

composer test

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件