承接 lygav/php-slackbot 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lygav/php-slackbot

最新稳定版本:0.0.4

Composer 安装命令:

composer require lygav/php-slackbot

包简介

Simple, easy to use, PHP package for sending messages to Slack. Send pretty, colourful messages with rich attachments quickly with this friendly API

README 文档

README

Build Status Scrutinizer Packagist Packagist Pre Release

Simple, easy to use, PHP package for sending messages to Slack.
Send pretty, colourful messages with rich attachments quickly with this friendly API.

Compatible with PHP >= 5.3

Installation

Via composer

"require": {
   "lygav/php-slackbot": "0.0.*"
}

Without composer, via PHAR

From the command line, enter into the cloned repository dir and run:

php makephar

You will see that a new file was created named "phpslackbot.phar". Then in your application:

include 'path/to/phpslackbot.phar';

The rest is the same as when installed with 'composer'

Your first message

$bot = new Slackbot("https://hooks.slack.com/services/your/incoming/hook");
$bot->text("Hi")->send();

Direct messages

$bot->text("Hi all!")
    ->from("username")
    ->toChannel("mychannel")
    ->send();

Create pretty, colorful attachments easily

$bot->attach(
    $bot->buildAttachment("fallback text")
    ->enableMarkdown()
    ->setText("We can have *mrkdwn* `code` _italic_ also in attachments")
    )
    ->toGroup("mygroup")
    ->send();

Customise freely

$attachment = $bot->buildAttachment("fallback text"/* mandatory by slack */)
    ->setPretext("pretext line")
    ->setText("attachment body text")
    /*
      Human web-safe colors automatically
      translated into HEX equivalent
    */
    ->setColor("lightblue")
    ->setAuthor("me")
    ->addField("short field", "i'm inline", TRUE)
    ->addField("short field 2", "i'm also inline", TRUE)
    ->setImageUrl("http://my-website.com/path/to/image.jpg");

$bot->attach($attachment)->send();

Set/ Override every possible setting

$options = array(
            'username' => 'my-bot-name',
            'icon_emoji' => ':icon name:',
            'icon_url' => 'http://someicon.com',
            'channel' => '#test-channel'
        );
        
$bot = new Slackbot($url, $options);
$bot->text("check out bot new icon")->send();

// Choose to override 'last minute' (ex. when dealing with multiple consequtive messages)
$bot->text("check out bot new icon")->send(array("username" => "other-bot-name"));

Advanced Usage

Use custom transfer handlers

$handler = new MockHandler();
$bot     = new SlackBot($url, ['handler' => $handler]);
$bot->text("some text")
    ->from("my-test-bot")
    ->toGroup("bot-testing")
    ->send();

统计信息

  • 总下载量: 386.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 38
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 1

GitHub 信息

  • Stars: 38
  • Watchers: 5
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-02