• Stars
    star
    486
  • Rank 87,153 (Top 2 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 3 years ago
  • Updated almost 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

推送通知 sdk(Bark、Chanify、钉钉群机器人、Discord、邮件、飞书群机器人、Gitter、Google Chat、iGot、Logger、Mattermost、Microsoft Teams、Now Push、Ntfy、PushBack、Push、PushDeer、Pushover、PushPlus、QQ 频道机器人、Rocket Chat、Server 酱、Showdoc Push、Slack、Telegram、Webhook、企业微信群机器人、息知、一封传话、Zulip)。

notify

简体中文 | ENGLISH

推送通知 sdk(Bark、Chanify、钉钉群机器人、Discord、邮件、飞书群机器人、Gitter、Google Chat、iGot、Logger、Mattermost、Microsoft Teams、Now Push、Ntfy、PushBack、Push、PushDeer、Pushover、PushPlus、QQ 频道机器人、Rocket Chat、Server 酱、Showdoc Push、Slack、Telegram、Webhook、企业微信群机器人、息知、一封传话、Zulip)。

Tests Check & fix styling codecov Latest Stable Version Total Downloads License

相关项目

平台支持

环境要求

  • PHP >= 7.2

安装

composer require guanguans/notify -vvv

使用

Bark
use Guanguans\Notify\Factory;
use Guanguans\Notify\Clients\Client;

$barkMessage = new \Guanguans\Notify\Messages\BarkMessage([
    'title' => 'This is title.',
    'body' => 'This is body.',
    'copy' => 'This is copy.',
    'url' => 'https://github.com/guanguans/notify',
    'sound' => 'bell',
    'group' => 'group',
    // 'icon' => 'https://avatars0.githubusercontent.com/u/25671453?s=200&v=4',
    // 'group' => 'group',
    // 'level' => 'passive',
    // 'badge' => 5,
    // 'isArchive' => 1,
    // 'autoCopy' => 1,
    // 'automaticallyCopy' => 1,
]);
Factory::bark()
    // ->setBaseUri('The server address of your own deployment.')
    ->setToken('ihnPXb8KDj9dHStfQ5c')
    ->setMessage($barkMessage)
    ->sending(function (Client $client){
        // do something for before send
        dump($client->getRequestParams());
    })
    ->sended(function (Client $client){
        // do something for after send
        dump($client->getResponse());
    })
    ->send();
Chanify
// Text Message
Factory::chanify()
    // ->setBaseUri('The server address of your own deployment.')
    ->setToken('fh4gGEiJBQVdIWlVKS1JORVY0UlVETFZYVVpRTlNLTlVZVlZPT1JFGhR7vAyf8Uj5UQhhK4n6QfVzih96QyIECAEQAQ.E0eBnLbfNwWrWZ1YSAZfkCQWZAPdBl6pVr26lRf6Srs')
    ->setMessage((new \Guanguans\Notify\Messages\Chanify\TextMessage([
        'title'    => 'This is title.',
        'text'     => 'This is text.',
        // 'copy'     => 'This is copy.',
        // 'actions'  => [
        //     "ActionName1|http://<action host>/<action1>",
        //     "ActionName2|http://<action host>/<action2>",
        // ],
        // 'autocopy' => 0,
        // 'sound'    => 0,
        // 'priority' => 10,
    ])))
    ->send();

// Link Message
Factory::chanify()
    // ->setBaseUri('The server address of your own deployment.')
    ->setToken('fh4gGEiJBQVdIWlVKS1JORVY0UlVETFZYVVpRTlNLTlVZVlZPT1JFGhR7vAyf8Uj5UQhhK4n6QfVzih96QyIECAEQAQ.E0eBnLbfNwWrWZ1YSAZfkCQWZAPdBl6pVr26lRf6Srs')
    ->setMessage((new \Guanguans\Notify\Messages\Chanify\LinkMessage([
        'link'     => 'https://github.com/guanguans/notify',
        // 'sound'    => 0,
        // 'priority' => 10,
    ])))
    ->send();
钉钉群机器人
// Text Message
Factory::dingTalk()
    ->setToken('c44fec1ddaa8a833156efb77b7865d62ae13775418030d94d05da08bfca73e')
    ->setSecret('SECc32bb7345c0f73da2b9786f0f7dd5083bd768a29b82e6d460149d730eee51730')
    ->setMessage((new \Guanguans\Notify\Messages\DingTalk\TextMessage([
        'content'   => 'This is content(keyword).',
        // 'atMobiles' => [13948484984],
        // 'atDingtalkIds' => [123456],
        // 'isAtAll'   => false,
    ])))
    ->send();

// Link Message
Factory::dingTalk()
    ->setToken('c44fec1ddaa8a833156efb77b7865d62ae13775418030d94d05da08bfca73e')
    ->setSecret('SECc32bb7345c0f73da2b9786f0f7dd5083bd768a29b82e6d460149d730eee51730')
    ->setMessage((new \Guanguans\Notify\Messages\DingTalk\LinkMessage([
        'title'      => 'This is content.',
        'text'       => 'This is text(keyword).',
        'messageUrl' => 'https://github.com/guanguans/notify',
        'picUrl'     => 'https://avatars.githubusercontent.com/u/22309277?v=4',
    ])))
    ->send();

// Markdown Message
Factory::dingTalk()
    ->setToken('c44fec1ddaa8a833156efb77b7865d62ae13775418030d94d05da08bfca73e')
    ->setSecret('SECc32bb7345c0f73da2b9786f0f7dd5083bd768a29b82e6d460149d730eee51730')
    ->setMessage((new \Guanguans\Notify\Messages\DingTalk\MarkdownMessage([
        'title' => 'This is title.',
        'text'  => '> This is text(keyword).',
        // 'atMobiles' => [13948484984],
        // 'atDingtalkIds' => [123456],
        // 'isAtAll'   => false,
    ])))
    ->send();

// Feed Card Message
$message = new \Guanguans\Notify\Messages\DingTalk\FeedCardMessage([
    'title'      => 'This is title(keyword) 0.',
    'messageURL' => 'https://github.com/guanguans/notify',
    'picURL'     => 'https://avatars.githubusercontent.com/u/22309277?v=4'
]);
Factory::dingTalk()
    ->setToken('c44fec1ddaa8a833156efb77b7865d62ae13775418030d94d05da08bfca73e')
    ->setSecret('SECc32bb7345c0f73da2b9786f0f7dd5083bd768a29b82e6d460149d730eee51730')
    ->setMessage($message)
    ->send();

// Single Action Card Message
Factory::dingTalk()
    ->setToken('c44fec1ddaa8a833156efb77b7865d62ae13775418030d94d05da08bfca73e')
    ->setSecret('SECc32bb7345c0f73da2b9786f0f7dd5083bd768a29b82e6d460149d730eee51730')
    ->setMessage(new \Guanguans\Notify\Messages\DingTalk\SingleActionCardMessage([
        'title'       => 'This is title(keyword).',
        'text'        => 'This is text.',
        'singleTitle' => 'This is singleTitle.',
        'singleURL'   => 'https://avatars.githubusercontent.com/u/22309277?v=4',
        // 'btnOrientation' => 1
    ]))
    ->send();

// Btns Action Card Message
$message = new \Guanguans\Notify\Messages\DingTalk\BtnsActionCardMessage([
    'title'          => 'This is title(keyword).',
    'text'           => 'This is text.',
    // 'hideAvatar'     => 1,
    // 'btnOrientation' => 1,
    'btns' => [
        [
            'title'     => 'This is title 1',
            'actionURL' => 'https://github.com/guanguans/notify',
        ]
    ]
]);
$message->addBtn([
    'title'     => 'This is title 2',
    'actionURL' => 'https://github.com/guanguans/notify',
]);
Factory::dingTalk()
    ->setToken('c44fec1ddaa8a833156efb77b7865d62ae13775418030d94d05da08bfca73e')
    ->setSecret('SECc32bb7345c0f73da2b9786f0f7dd5083bd768a29b82e6d460149d730eee51730')
    ->setMessage($message)
    ->send();
Discord
$message = new \Guanguans\Notify\Messages\DiscordMessage([
    'content' => 'This is content.',
    //'username' => 'notify bot.',
    //'avatar_url' => 'https://avatars.githubusercontent.com/u/22309277?v=4',
    //'tts' => false,
    //'embeds' => $embed = [
    //    'title' => 'This is title.',
    //    'type' => 'This is type.',
    //    'description' => 'This is description.',
    //    'url' => 'https://avatars.githubusercontent.com/u/22309277?v=4',
    //    'color' => '0365D6',
    //    'footer' => [
    //        'text' => 'This is text.',
    //        'icon_url' => 'https://avatars.githubusercontent.com/u/22309277?v=4',
    //    ],
    //    'image' => [
    //        'url' => 'https://avatars.githubusercontent.com/u/22309277?v=4',
    //    ],
    //    'thumbnail' => [
    //        'url' => 'https://avatars.githubusercontent.com/u/22309277?v=4',
    //    ],
    //    'author' => [
    //        'name' => 'This is name.',
    //        'url' => 'https://avatars.githubusercontent.com/u/22309277?v=4.',
    //        'icon_url' => 'https://avatars.githubusercontent.com/u/22309277?v=4',
    //    ],
    //    'fields' => [
    //        [
    //            'name' => 'This is name.',
    //            'value' => 'This is value.',
    //            'inline' => false,
    //        ],
    //    ],
    ],
]);

Factory::discord()
    ->setWebhookUrl('https://discord.com/api/webhooks/955407924304425000/o7RfCGxek_o8kfR6Q9i')
    ->setMessage($message)
    ->send();
邮件
# 安装依赖
$ composer require symfony/mailer -vvv
$email = \Guanguans\Notify\Messages\EmailMessage::create()
    ->from('[email protected]')
    ->to('[email protected]')
    //->cc('[email protected]')
    //->bcc('[email protected]')
    //->replyTo('[email protected]')
    // ->priority(\Guanguans\Notify\Messages\EmailMessage::PRIORITY_HIGH)
    ->subject('This is a testing for notify.')
    // ->html('<p>Sending emails is fun again!</p>')
    ->text('This is a testing.');

Factory::mailer()
    ->setDsn('smtp://user:[email protected]:465?verify_peer=0')
    ->setMessage($email)
    ->send();
飞书群机器人
// Text Message
Factory::feiShu()
    ->setToken('b6eb70d9-6e19-4f87-af48-348b028186')
    ->setSecret('iigDOvnsIn6aFS1pYHHEHh')
    ->setMessage(new \Guanguans\Notify\Messages\FeiShu\TextMessage('This is title(keyword).'))
    ->send();

// Post Message
$post = [
    'zh_cn' => [
        'title'   => '项目更新通知',
        'content' => [
            [
                [
                    "tag"  => "text",
                    "text" => "项目有更新(keyword)"
                ]
            ]
        ]
    ]
];
Factory::feiShu()
    ->setToken('b6eb70d9-6e19-4f87-af48-348b028186')
    ->setSecret('iigDOvnsIn6aFS1pYHHEHh')
    ->setMessage(new \Guanguans\Notify\Messages\FeiShu\PostMessage($post))
    ->send();

// Image Message
Factory::feiShu()
    ->setToken('b6eb70d9-6e19-4f87-af48-348b028186')
    ->setSecret('iigDOvnsIn6aFS1pYHHEHh')
    ->setMessage(new \Guanguans\Notify\Messages\FeiShu\ImageMessage('img_ecffc3b9-8f14-400f-a014-05eca1a4xxxx'))
    ->send();

// ShareChat Message
Factory::feiShu()
    ->setToken('b6eb70d9-6e19-4f87-af48-348b028186')
    ->setSecret('iigDOvnsIn6aFS1pYHHEHh')
    ->setMessage(new \Guanguans\Notify\Messages\FeiShu\ShareChatMessage('oc_f5b1a7eb27ae2c7b6adc2a74fafxxxxx'))
    ->send();

// Card Message
$card = [
    'elements' => [
        [
            'tag'  => 'div',
            'text' => [
                'content' => '**西湖(keyword)**,位于浙江省杭州市西湖区龙井路1号,杭州市区西部,景区总面积49平方千米,汇水面积为21.22平方千米,湖面面积为6.38平方千米。',
                'tag'     => 'lark_md',
            ],
        ],
    ],
];
Factory::feiShu()
    ->setToken('b6eb70d9-6e19-4f87-af48-348b0281866c')
    ->setSecret('iigDOvnsIn6aFS1pYHHEHh')
    ->setMessage(new \Guanguans\Notify\Messages\FeiShu\CardMessage($card))
    ->send();
Gitter
Factory::gitter()
    ->setToken('b9e7931ecacb08b7ab4df5e98bc149d33d7faf1')
    ->setRoomId('61af21b96da03739848bfef')
    ->setMessage(new \Guanguans\Notify\Messages\GitterMessage('This is testing.'))
    ->send();
Google Chat
Factory::googleChat()
    ->setToken('accessToken')
    ->setKey('accessKey')
    ->setSpace('space')
    // ->setThreadKey('threadKey')
    ->setMessage(new \Guanguans\Notify\Messages\GoogleChatMessage([
        'text' => 'This is a testing.',
    ]))
    ->send();
iGot
Factory::iGot()
    ->setToken('5dcd2f91d38cc47447414')
    ->setMessage(
        new \Guanguans\Notify\Messages\IGotMessage([
            'content' => 'This is content.',
            // 'title' => 'This is title.',
            // 'url' => 'https://www.github.com/guanguans/notify',
            // 'automaticallyCopy' => 1,
            // 'urgent' => 1,
            // 'copy' => 'This is copy.',
            // 'detail' => [
            //     'title' => 'This is detail title.',
            //     'content' => 'This is detail content.',
            // ],
        ])
    )
    ->send();
Logger
Factory::logger()
    ->setLogger(new \Psr\Log\NullLogger())
    // ->setLevel('warning')
    ->setMessage(new \Guanguans\Notify\Messages\LoggerMessage('This is a testing.'))
    ->send();
Mattermost
Factory::mattermost()
    ->setBaseUri('https://guanguans.cloud.mattermost.com')
    ->setToken('r7jezodttibgueijpahyyfh1qa')
    ->setMessage(
        new \Guanguans\Notify\Messages\MattermostMessage([
            'channel_id' => 'sat5ohbs5byixd86tmxtk13',
            'message' => 'This is a testing.',
            // 'is_pinned' => true,
            // 'create_at' => 1639041968509,
            // 'edit_at' => 1639041968509,
            // 'root_id' => '',
            // 'original_id' => '',
            // 'type' => '',
            // 'pending_post_id' => '1639041968509abc',
            // 'participants' => null,
            // 'props' => ['key' => 'value'],
            // 'file_ids' => ['o3x4y157jff5xydf5m91bft1oo'],
        ])
    )
    ->send();
Microsoft Teams
$microsoftTeamsMessage = new MicrosoftTeamsMessage([
    'correlationId' => 'This is correlationId.',
    'expectedActors' => [
        '[email protected]',
    ],
    'originator' => 'This is originator.',
    'summary' => 'This is summary.',
    'themeColor' => '0076D7',
    'hideOriginalBody' => false,
    'title' => 'This is title.',
    'text' => 'This is text.',
    'sections' => [],
    'potentialAction' => [],
]);

$microsoftTeamsMessage
    ->addSection([
        'title' => 'This is title.',
        'startGroup' => true,
        'activityImage' => 'This is activityImage.',
        'activityTitle' => 'This is activityTitle.',
        'activitySubtitle' => 'This is activitySubtitle.',
        'activityText' => 'This is activityText.',
        'heroImage' => 'This is heroImage.',
        'text' => 'This is text.',
        'facts' => [
            [
                'name' => 'This is name.',
                'value' => 'This is value.',
            ],
        ],
        'images' => [
            'This is images.',
        ],
        'potentialAction' => [],
    ])
    ->addPotentialAction([
        '@type' => 'OpenUri',
        'name' => 'This is name.',
        'targets' => [
            [
                'os' => 'default',
                'uri' => 'https://learn.microsoft.com/outlook/actionable-messages',
            ],
        ],
    ])
    ->addPotentialAction([
        '@type' => 'HttpPOST',
        'name' => 'This is name.',
        'target' => 'https://learn.microsoft.com/outlook/actionable-messages',
        'headers' => [
            [
                'name' => 'X-Version',
                'value' => 'v1.0.0',
            ],
        ],
        'body' => [
            'field' => 'value',
        ],
        'bodyContentType' => 'application/x-www-form-urlencoded',
    ])
    ->addPotentialAction([
        '@type' => 'ActionCard',
        'name' => 'This is name.',
        'inputs' => [
            [
                '@type' => 'TextInput',
                'id' => 'comment',
                'isRequired' => true,
                'title' => 'This is title.',
                'value' => 'This is value.',
                'isMultiline' => true,
            ],
        ],
        'actions' => [],
    ])
    ->addPotentialAction([
        '@type' => 'InvokeAddInCommand',
        'name' => 'This is name.',
        'addInId' => '527104a1-f1a5-475a-9199-7a968161c870',
        'desktopCommandId' => 'show',
        'initializationContext' => [
            'property1' => 'This is property1.',
            'property2' => 'This is property2.',
        ],
    ]);

Factory::microsoftTeams()
    ->setWebhookUrl('url')
    ->setMessage($microsoftTeamsMessage)
    ->send();
Now Push
// Note Message
Factory::nowPush()
    ->setToken('vpNVue4teSl93ijHBVT6sDT4sHLP7OMTzFCfdQb0QxLYvL')
    ->setMessage(new \Guanguans\Notify\Messages\NowPush\NoteMessage('This is a note.'))
    ->send();

// Image Message
Factory::nowPush()
    ->setToken('vpNVue4teSl93ijHBVT6sDT4sHLP7OMTzFCfdQb0QxLYvL')
    ->setMessage(new \Guanguans\Notify\Messages\NowPush\ImageMessage('https://www.nowpush.app/assets/img/welcome/welcome-mockup.png'))
    ->send();

// Link Message
Factory::nowPush()
    ->setToken('vpNVue4teSl93ijHBVT6sDT4sHLP7OMTzFCfdQb0QxLYvL')
    ->setMessage(new \Guanguans\Notify\Messages\NowPush\LinkMessage('https://github.com/guanguans/notify'))
    ->send();

// User Info
Factory::nowPush()
    ->setToken('vpNVue4teSl93ijHBVT6sDT4sHLP7OMTzFCfdQb0QxLYvL')
    ->getUser();
Ntfy
$ntfyMessage = new NtfyMessage([
    'topic' => 'guanguans',
    'message' => 'This is message.',
    'title' => 'This is title.',
    'priority' => 1,
    'tags' => ['tag1', 'tag2'],
    'click' => 'https://example.com',
    'attach' => 'https://www.guanguans.cn',
    'icon' => 'https://www.guanguans.cn',
    'filename' => 'file.jpg',
    'cache' => 'no',
    'firebase' => 'no',
    // 'actions' => [],
    // 'delay' => '30min, 9am',
    // 'email' => '[email protected]',
]);

$ntfyMessage
    ->addAction([
        'action' => 'broadcast',
        'label' => 'This is label.',
        'intent' => 'This is intent.',
        'extras' => [
            'field' => 'value',
        ],
    ])
    ->addAction([
        'action' => 'http',
        'label' => 'This is label.',
        'url' => 'https://www.guanguans.cn',
        'method' => 'POST',
        'headers' => [
            'Authorization' => 'Bearer ...',
        ],
        'body' => '{"field":"value"}',
    ])
    ->addAction([
        'action' => 'view',
        'label' => 'This is label.',
        'url' => 'https://www.guanguans.cn',
        'clear' => true,
    ]);

Factory::ntfy()
    // ->setBaseUri('The server address of your own deployment.')
    // ->setUsername('username')
    // ->setPassword('password')
    ->setMessage($ntfyMessage)
    ->send();
PushBack
Factory::pushBack()
    ->setToken('at_uDCCK8gdHJPN613lASV')
    // ->setSynchonousMode()
    ->setMessage(
        new \Guanguans\Notify\Messages\PushBackMessage([
            'id' => 'User_1730',
            'title' => 'This is title.',
            // 'body' => 'This is body.',
            // 'action1' => 'action1',
            // 'action2' => 'action2',
            // 'reply' => 'reply',
        ])
    )
    ->send();
Push
Factory::push()
    ->setToken('5db80e8a-1f9b-4f98-929a-75892cedc')
    ->setMessage(
        new \Guanguans\Notify\Messages\PushMessage([
            'title' => 'This is a title.',
            'body' => 'This is a body.',
            // 'link' => 'https://github.com/guanguans/notify',
            // 'image' => 'https://www.nowpush.app/assets/img/welcome/welcome-mockup.png',
        ])
    )
    ->send();
PushDeer
Factory::pushDeer()
    ->setToken('PDU8024TTt9Yvx4wkm08SmSXAY9pnPycl5RrB')
    ->setMessage(new \Guanguans\Notify\Messages\PushDeerMessage('## This is text.', '> This is desp.', 'markdown'))
    ->send();
Pushover
Factory::pushover()
    ->setToken('abs9tevjnpu2p7x1yii8uf23')
    ->setUserToken('uz86ivgu7xkizpdpdo65vw2c')
    ->setMessage(
        new \Guanguans\Notify\Messages\PushoverMessage([
            'message' => 'This is message.',
            // 'title' => 'This is title.',
            // 'timestamp' => time(),
            // 'priority' => 2,
            // 'url' => 'https://www.guanguans.cn',
            // 'url_title' => 'This is URL title.',
            // 'sound' => 'none',
            // 'retry' => 60,
            // 'expire' => 3600,
            // 'html' => 1,
            // 'monospace' => 0,
            // 'callback' => 'https://www.guanguans.cn/',
            // 'device' => 'This is device.',
            // 'attachment' => '/Users/yaozm/Downloads/xxx.png',
        ])
    )
    ->send();

// sounds
Factory::pushover()
    ->setToken('abs9tevjnpu2p7x1yii8uf23')
    ->sounds();
PushPlus
Factory::pushPlus()
    ->setToken('762e3f7efd764ad5acaa9cc26ac20')
    ->setMessage(new \Guanguans\Notify\Messages\PushPlusMessage([
        'content' => 'This is content.',
        // 'title' => 'This is title.',
        // 'template' => 'html',
        // 'topic' => 'topic',
    ]))
    ->send();
QQ 频道机器人
# 安装依赖
$ composer require textalk/websocket -vvv
// 获取用户频道列表
Factory::qqChannelBot()
    ->setAppid(102001)
    ->setToken('eghXYBXQH0QXBByb8Zj4VeRGterQG')
    ->getUserChannels();

// 获取子频道列表    
Factory::qqChannelBot()
    ->setAppid(102001)
    ->setToken('eghXYBXQH0QXBByb8Zj4VeRGterQG')
    ->getSubChannels(5099581822453968); // 频道 ID

// 发送频道消息
Factory::qqChannelBot()
    ->setAppid(102001)
    ->setToken('eghXYBXQH0QXBByb8Zj4VeRGterQG')
    ->setChannelId('4317') // 子频道 ID
    // ->sandboxEnvironment()
    // ->setSecret('3yfBSaUCfy3zlQr5')
    ->setMessage(
        \Guanguans\Notify\Messages\QqChannelBotMessage::create([
            'content' => 'This is content.',
            'image' => 'https://avatars.githubusercontent.com/u/22309277?v=4',
            // 'msg_id' => '3yfBSa',
            // 'embed' => [],
            // 'ark' => [],
            // 'message_reference' => [],
            // 'markdown' => [],
        ])
    )
    ->send();
Rocket Chat
Factory::rocketChat()
    ->setToken('EemSHx9ioqdmrWouS/yYpmhqDSyd7CqmSAnyBfKezLyzotswbRSpkD9MCNxqtPL')
    ->setBaseUri('https://guanguans.rocket.chat')
    ->setMessage(
        new \Guanguans\Notify\Messages\RocketChatMessage([
            'alias' => '报警机器人',
            'emoji' => ':warning:',
            'text' => 'This is a testing. ',
            // 'attachments' => [
            //     [
            //         'title' => 'This is a title.',
            //         'title_link' => 'https://rocket.chat',
            //         'text' => 'This is a text.',
            //         'image_url' => 'http://www.xxx.png',
            //         'color' => '#764FA5',
            //     ],
            // ],
        ])
    )
    ->send();
Server 酱
Factory::serverChan()
    ->setToken('SCT35149Thtf1g2Bc14QJuQ6HFpW5YG')
    ->setMessage(new \Guanguans\Notify\Messages\ServerChanMessage('This is title.', 'This is desp.'))
    ->send();

// Check
Factory::serverChan()->check(3334849, 'SCTJlJV1J87hS');
Showdoc Push
Factory::showdocPush()
    ->setToken('f096edb95f92540219a41e47060eeb6d9461')
    ->setMessage(new \Guanguans\Notify\Messages\ShowdocPushMessage('This is title.', 'This is content.'))
    ->send();
Slack
$message = new \Guanguans\Notify\Messages\SlackMessage([
    'text' => 'This is text.',
    //'channel' => '#general',
    //'username' => 'notify bot',
    //'icon_emoji' => ':ghost:',
    //'icon_url' => 'https://avatars.githubusercontent.com/u/22309277?v=4',
    //'unfurl_links' => true,
    //'attachments' => $attachment = [
    //    'fallback' => 'Required text summary of the attachment',
    //    'text' => 'Optional text that should appear within the attachment',
    //    'pretext' => 'Optional text that should appear above the formatted data',
    //    'color' => '#36a64f',
    //    'fields' => [
    //        [
    //            'title' => 'Required Field Title',
    //            'value' => 'Text value of the field.',
    //            'short' => false,
    //        ],
    //    ],
    //],
]);

Factory::slack()
    ->setWebhookUrl('https://hooks.slack.com/services/TPU9A98MT/B038KNUC0GY/6pKH3vfa3mjlUPcgLSjzR')
    ->setMessage($message)
    ->send();
Telegram
// getUpdates(Chat ID)
Factory::telegram()
    ->setToken('5146570:AAF-Pi1MBPa46wdyobfZZdZL1-PlDfrZ')
    ->getUpdates();

// Text
\Guanguans\Notify\Messages\Telegram\TextMessage::create([
    'chat_id' => 50443416,
    'text' => '*This is text*',
    'parse_mode' => 'MarkdownV2',
    // 'entities' => [],
    // 'disable_web_page_preview' => true,
    // 'disable_notification' => true,
    // 'protect_content' => true,
    // 'reply_to_message_id' => 5,
    // 'allow_sending_without_reply' => true,
    // 'reply_markup' => [],
]);

Factory::telegram()
    ->setToken('5146570195:AAF-Pi1MBPa46wdyobfZZdZL')
    ->setMessage($message)
    ->send();
Webhook
$message = \Guanguans\Notify\Messages\WebhookMessage::create([
    'content' => 'This is content.',
    'username' => 'notify bot.',
])
// ->setHeaders(['Accept' => '*/*'])
// ->setQuery([['foo' => 'bar']])
->setVerify(false);

Factory::webhook()
    ->setUrl('https://discord.com/api/webhooks/955407924304425000/o7RfCGxek_o8kfR6Q9iGKtTdRJ')
    // ->setRequestMethod('postJson')
    ->setMessage($message)
    ->send();
企业微信群机器人
// Text Message
Factory::weWork()
    ->setToken('73a3d5a3-ceff-4da8-bcf3-ff5891778f')
    ->setMessage((new \Guanguans\Notify\Messages\WeWork\TextMessage([
        'content'               => 'This is content.',
        // 'mentioned_list'        => ["wangqing", "@all"],
        // 'mentioned_mobile_list' => ["13800001111", "@all"],
    ])))
    ->send();

// Markdown Message
Factory::weWork()
    ->setToken('73a3d5a3-ceff-4da8-bcf3-ff5891778f')
    ->setMessage(new \Guanguans\Notify\Messages\WeWork\MarkdownMessage("# This is title.\n This is content."))
    ->send();

// Image Message
Factory::weWork()
    ->setToken('73a3d5a3-ceff-4da8-bcf3-ff5891778f')
    ->setMessage(new \Guanguans\Notify\Messages\WeWork\ImageMessage('https://avatars.githubusercontent.com/u/22309277?v=4'))
    ->send();

// News Message
$message = new \Guanguans\Notify\Messages\WeWork\NewsMessage([
    'title'       => 'This is title1.',
    'description' => 'This is description.',
    'url'         => 'https://github.com/guanguans/notify',
    'picurl'      => 'https://avatars.githubusercontent.com/u/22309277?v=4',
]);
$message->addArticle([
    'title'       => 'This is title2.',
    'description' => 'This is description.',
    'url'         => 'https://github.com/guanguans/notify',
    'picurl'      => 'https://avatars.githubusercontent.com/u/22309277?v=4',
]);
Factory::weWork()
    ->setToken('73a3d5a3-ceff-4da8-bcf3-ff5891778f')
    ->setMessage($message)
    ->send();
息知
// Single
Factory::xiZhi()
    // ->setType('single')
    ->setToken('XZd60aea56567ae39a1b1920cbc42bb5')
    ->setMessage(new \Guanguans\Notify\Messages\XiZhiMessage('This is title.', 'This is content.'))
    ->send();

// Channel
Factory::xiZhi()
    ->setType('channel')
    ->setToken('XZ8da15b55a6725497232d87298bcd34')
    ->setMessage(new \Guanguans\Notify\Messages\XiZhiMessage('This is title.', 'This is content.'))
    ->send();
一封传话
Factory::yiFengChuanHua()
    ->setToken('204dd77ce4a6f221')
    ->setMessage(new \Guanguans\Notify\Messages\YiFengChuanHuaMessage([
        'head' => 'This is title.',
        'body' => 'This is content.',
    ]))
    ->send();
Zulip
// Private Message
Factory::zulip()
    ->setToken('Mc0b7YBmibOVjLdk7KKSpT9SJLi1h')
    ->setEmail('[email protected]')
    ->setBaseUri('https://coole.zulipchat.com')
    ->setMessage(new \Guanguans\Notify\Messages\Zulip\PrivateMessage('[email protected]', 'This is testing.'))
    ->send();

// Stream Message
Factory::zulip()
    ->setToken('Mc0b7YBmibOVjLdk7KKSpT9SJLi1h')
    ->setEmail('[email protected]')
    ->setBaseUri('https://coole.zulipchat.com')
    ->setMessage(new \Guanguans\Notify\Messages\Zulip\StreamMessage([
        'to' => 'coole',
        'content' => 'This is testing.',
        'topic' => 'bug',
        //'queue_id' => '1593114627:0',
        //'local_id' => '100.01',
    ]))
    ->send();

测试

composer test

变更日志

请参阅 CHANGELOG 获取最近有关更改的更多信息。

贡献指南

请参阅 CONTRIBUTING 有关详细信息。

安全漏洞

请查看我们的安全政策了解如何报告安全漏洞。

贡献者

协议

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

More Repositories

1

favorite-link

❤️ 每天收集喜欢的开源项目 | RSS 订阅 | 快知 app 订阅
Python
2,026
star
2

notes

📔 Linux、MySQL、Nginx、PHP、Git、Shell 等笔记
JavaScript
1,983
star
3

music-dl

Music Searcher and Downloader. - 音乐搜索下载器。
PHP
418
star
4

dnmp-plus

🐳Docker的LNMP一键安装开发环境 + PHP非侵入式监控平台xhgui(优化系统性能、定位Bug神器)
Shell
288
star
5

laravel-soar

SQL optimizer and rewriter for laravel. - laravel 的 SQL 优化器和重写器。
PHP
167
star
6

soar-php

SQL optimizer and rewriter. - SQL 优化器、重写器(辅助 SQL 调优)。
PHP
158
star
7

id-validator

China ID number validator. - 中国身份证号验证器。
Go
157
star
8

ai-commit

Automagically generate conventional git commit messages with AI. - 使用 AI 自动生成约定式 git 提交信息。
PHP
87
star
9

think-soar

SQL optimizer and rewriter extension package for thinkphp5/6 framework.
PHP
80
star
10

laravel-exception-notify

Laravel 中异常监控报警通知(Bark、Chanify、钉钉群机器人、Discord、飞书群机器人、邮件、PushDeer、QQ 频道机器人、Server 酱、Slack、Telegram、企业微信群机器人、息知)。
PHP
69
star
11

guanguans.github.io

guanguans 博客
51
star
12

yii-pay

适配于 Yii 的 alipay 和 wechat 的支付扩展包
PHP
42
star
13

dcat-login-captcha

dcat admin login captcha. - dcat admin 登录验证码。
PHP
33
star
14

laravel-dump-sql

Assist laravel application to obtain complete sql statement. - 辅助 laravel 应用获取完整的 sql 语句。
PHP
31
star
15

laravel-skeleton

laravel 模板仓库。
PHP
22
star
16

coole

Coole is a PHP framework built on open source components. - Coole 是一个基于开源组件包构建的 PHP 框架。
PHP
19
star
17

yii-event

Elegant usage events in Yii. - 在 Yii 中优雅的使用事件。
PHP
13
star
18

yii-log-target

Multiple channels of Yii exception notification(Bark、Chanify、DingTalk、FeiShu、ServerChan、WeWork、XiZhi). - 多种通道的 Yii 异常通知(Bark、Chanify、钉钉群机器人、飞书群机器人、Server 酱、企业微信群机器人、息知)。
PHP
9
star
19

yii-var-dumper

Bringing the symfony/var-dumper to Yii. - 将 symfony/var-dumper 集成到 Yii。
PHP
7
star
20

laravel-code-runner

Run the PHP code in the browser. - 在浏览器中运行 PHP 代码。
PHP
7
star
21

package-skeleton

A PHP package template repository. - 一个 PHP 软件包模板存储库。
PHP
7
star
22

tiny-yii

简化版 Yii2,只保留 Yii2 最核心的部分(base),便于深入理解 Yii2。
PHP
7
star
23

swoole-chat

基于 ThinkPHP5 和 Swoole 开发的聊天室
PHP
6
star
24

yii-goaop

Bringing the goaop/framework to Yii. - 将 goaop/framework 集成到 Yii。在 Yii 中优雅的面向切面编程。
PHP
6
star
25

yii-jpush

适配于 Yii 的极光推送 SDK
PHP
5
star
26

poetry

基于 Coole 开发部署在 Vercel 上的免费诗词 API 接口。
Twig
5
star
27

design-patterns-php

设计模式 PHP 示例代码。
PHP
5
star
28

valet-drivers

A list of drivers for laravel-valet. - laravel-valet 的驱动列表。
PHP
5
star
29

guanguans-php-ext

一个简单的 PHP 扩展
C
5
star
30

eii

Core component separated from Yii2. - 从 Yii2 分离出来的核心组件。
PHP
5
star
31

di

A flexible dependency injection container based on the modification of illuminate/container. - 一个灵活的基于 illuminate/container 修改的依赖注入容器。
PHP
5
star
32

pipeline

An elegant PHP middleware pipeline. - 一个优雅的 PHP 中间件管道。
PHP
3
star
33

go-skeleton

A Go package template repository. - 一个 Go 软件包模板存储库。
Go
3
star
34

yii-dingtalk

适配于 Yii 的钉钉 SDK
PHP
2
star
35

graph-bed

Graph bed
2
star
36

json-format

Format json string.
PHP
2
star
37

upptime

📈 Uptime monitor and status page for guanguans, powered by @upptime
Markdown
2
star
38

dcloud-app-pay

DCloud app 支付 SDK
PHP
2
star
39

laravel-proxy-manager

Proxy Manager integration for Laravel. - Laravel 的代理管理器集成。
PHP
2
star
40

guanguans

2
star
41

uploadfile

通用文件上传类
PHP
2
star
42

translator

Go
1
star
43

monorepo-builder-worker

List of release worker collections for symplify/monorepo-builder.
PHP
1
star
44

stackedit

stackedit
1
star