承接 portlandlabs/slackbot 相关项目开发

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

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

portlandlabs/slackbot

Composer 安装命令:

composer create-project portlandlabs/slackbot

包简介

A Slackbot that uses the slack RTM API and the slack web API. Built on PSR components

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

This SlackBot is a fully featured slack bot in the style of old IRC bots with the power of new fancy bots. You can react to arbitrary messages like tracking emojis in a message like "Giving some ❤️ to @user", or build simple call and response style messages like @bot dosomething

Getting Started

Setup

First configure your slackbot by copying .env.dist to .env and configuring the required details

$ cp .env.dist > .env

Running the bot

The Slackbot is powered by a single PHP script, run it to get started:

$ php slackbot.php

Permissions and Roles

Slackbot actions are managed by roles. The available roles are Bot, User, and Admin

Role Extends How to Access
User - Don't be a bot
Admin User Use the bot in the configured Admin channel
Bot - Send a message through the Slack Web API with as_user disabled

Commands

Commands are triggered by events flowing through the RTM API. Any event with the type message will flow through the command stack.

A basic command defines ->shouldHandle(Message $message) and ->handle(Message $message), but SimpleCommand makes things a little easier to implement. Commands that extend SimpleCommand work much the same as console commands. Declare your $signature property and a run(Message $message, ArgumentManager $manager) method, and the super class will manage hooking everything up.

Adding commands to the bot

You can add commands to the bot through the bot's command manager:

$bot->commands()->addCommand(CustomCommand::class);

Adding Default Commands:
We've wrapped the default commands in a simple provider:

(new \PortlandLabs\Slackbot\Command\DefaultProvider())->register($bot);

Sending messages to slack

There are a few ways to send messages to slack from a command:

  1. RTM API with Typing indicator

    When using the RTM API you have the ability to trigger typing indicators (so that slack says the bot is typing)

    $this->bot->feignTyping($channel, $message)

    The result of this method is a Promise that resolves when Slack acknowledges the sent message.

  2. RTM API without typing

    If you don't want the (creepy) typing indicator and you want to be upfront with the fact that your bot doesn't type,

    $this->bot->rtm()->sendMessage($channel, $message)

    The result of this is also a Promise

  3. Web API with ability to Update

    The Web API uses HTTP to send messages to slack and so can be a bit slower than using the RTM API with the added benefit of a ton of added power.

    Simple Usage:
    The simplest usage is with the Payload Builder:

    $api = $this->bot->api();
    $api->getBuilder()->send($message)->to($channel)->withIcon($icon)->execute($api);
    
    // Update the previously sent message
    $api->getBuilder()->update()->withText($newText)->execute($api);

    Complex Usage:
    If you're looking for more power or for different endpoints, you can simply build payloads directly and send them with the API

    $payload = new ChatPostMessagePayload();
    $this->prepare($payload);
    
    // Send the payload
    $payloadResponse = $this->bot->api()->send($payload);

portlandlabs/slackbot 适用场景与选型建议

portlandlabs/slackbot 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 36 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 10 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 portlandlabs/slackbot 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 portlandlabs/slackbot 我们能提供哪些服务?
定制开发 / 二次开发

基于 portlandlabs/slackbot 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-01