phergie/phergie-irc-plugin-react-command 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

phergie/phergie-irc-plugin-react-command

最新稳定版本:2.0.0

Composer 安装命令:

composer require phergie/phergie-irc-plugin-react-command

包简介

Phergie plugin for parsing commands issued to the bot

README 文档

README

This repo is being kept for posterity and will be archived in a readonly state. If you're interested it can be forked under a new Composer namespace/GitHub organization.

phergie/phergie-irc-plugin-react-command

A plugin for Phergie to parse commands issued to the bot.

A common plugin to use in combination with this one is the CommandHelp plugin, which provides information about available commands and their usage to users.

Build Status

Install

The recommended method of installation is through composer.

composer require phergie/phergie-irc-plugin-react-command

See Phergie documentation for more information on installing plugins.

Configuration

new \Phergie\Irc\Plugin\React\Command\Plugin(array(

    // Select how you'd like the command to be triggered. 
    // Only 1 method supported at a time so make sure to remove unused methods.

    'prefix' => '!', // string denoting the start of a command

    // or

    'pattern' => '/^!/', // PCRE regular expression denoting the presence of a
                         // command

    // or

    'nick' => true, // true to match common ways of addressing the bot by its
                    // connection nick

))

Usage

This plugin monitors PRIVMSG and NOTICE events attempting to locate commands. When it finds one, it emits a custom event: 'command.COMMAND' where COMMAND is the matched command. Other plugins can subscribe to these events to be notified when a command is received.

Event parameters include an instance of CommandEvent (a subclass of UserEvent) that contains data about the parsed command and any other parameters that accompanied the original event that contained the command (e.g. an object that implements EventQueueInterface).

Here's an example of a plugin that handles a 'foo' command:

use Phergie\Irc\Plugin\React\Command\CommandEvent;
use Phergie\Irc\Bot\React\EventQueueInterface;
use Phergie\Irc\Bot\React\PluginInterface;

class FooPlugin implements PluginInterface
{
    public function getSubscribedEvents()
    {
        return array('command.foo' => 'handleFooCommand');
    }

    public function handleFooCommand(CommandEvent $event, EventQueueInterface $queue)
    {
        $commandName = $event->getCustomCommand();
        $fooParams = $event->getCustomParams();
        // ...
    }
}

In its getSubscribedEvents() implementation, this plugin indicates that it will listen for 'command.foo' events emitted by the Command plugin.

It specifies handleFooCommand() as the method for handling those events. Among this method's parameters is $event, an instance of the Command plugin's special CommandEvent class.

handleFooCommand() invokes two methods of $event: getCustomCommand(), which returns the command that was received ('foo' in this case) and is primarily useful when the same method is used to handle multiple commands, and getCustomParams(), which returns parameters specified when the command was issued.

Let's say the Command plugin is used with no configuration and receives this IRC event:

PRIVMSG #channel foo bar "two words" baz

It will emit the 'command.foo' event. The $event parameter sent to a handler method for that event will return 'foo' when its getCustomCommand() method is called and array('bar', 'two words', 'baz') when its getCustomParams() method is called.

Tests

To run the unit test suite:

curl -s https://getcomposer.org/installer | php
php composer.phar install
./vendor/bin/phpunit

License

Released under the BSD License. See LICENSE.

phergie/phergie-irc-plugin-react-command 适用场景与选型建议

phergie/phergie-irc-plugin-react-command 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.68k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2014 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「plugin」 「bot」 「irc」 「react」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 phergie/phergie-irc-plugin-react-command 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 4
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2014-04-20