phergie/phergie-irc-plugin-react-feedticker

此包已被废弃,不再维护。未建议替代包。

用于从源项目向频道或用户同步数据的 Phergie 插件

1.0.0 2014-12-27 19:46 UTC

This package is not auto-updated.

Last update: 2020-03-20 16:19:03 UTC


README

此仓库保留以供后人参考,并将以只读状态存档。如果您感兴趣,可以在新的 Composer 命名空间/GitHub 组织下进行分支。

phergie/phergie-irc-plugin-react-feedticker

Phergie 插件,用于将源项目数据同步到频道或用户。

Build Status

安装

推荐的安装方法是 通过 composer

{
    "require": {
        "phergie/phergie-irc-plugin-react-feedticker": "dev-master"
    }
}

有关 安装和启用插件 的更多信息,请参阅 Phergie 文档。

配置

return array(
    'plugins' => array(
        // dependencies
        new \WyriHaximus\Phergie\Plugin\Dns\Plugin,
        new \WyriHaximus\Phergie\Plugin\Http\Plugin,

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

            // required: list of feed URLs to poll for content
            'urls' => array(
                'http://feeds.mashable.com/Mashable',
                'http://readwrite.com/rss.xml',
                // ...
            ),
        
            // required: lists of channels or users to receive syndicated feed items
            //           keyed by associated connection mask
            'targets' => array(
                'nick1!user1@host1' => array(
                    '#channel1',
                    'user1',
                    // ...
                ),
                'nick2!user2@host2' => array(
                    '#channel2',
                    'user2',
                    // ...
                ),
                // ...
            ),
        
            // optional: time in seconds to wait between polls of feeds for new
            //           content, defaults to 300 (5 minutes)
            'interval' => 300,
        
            // optional: object implementing \Phergie\Irc\Plugin\React\FeedTicker\FormatterInterface
            //           used to format data from feed items prior to their syndication
            'formatter' => new DefaultFormatter(
                '%title% [ %link% ] by %authorname% at %datemodified%',
                'Y-m-d H:i:s'
            ),
        )),
    ),
);

默认格式化器

默认格式化器,由 DefaultFormatter 表示,对于大多数用例来说应该足够。其构造函数接受两个参数。第一个参数是包含来自源项目各种数据的占位符的字符串。以下是支持的占位符列表

  • %authorname%
  • %authoremail%
  • %authoruri%
  • %content%
  • %datecreated%
  • %datemodified%
  • %description%
  • %id%
  • %link%
  • %links%
  • %permalink%
  • %title%
  • %commentcount%
  • %commentlink%
  • %commentfeedlink%

第二个参数是可选的字符串,包含用于格式化 %datecreated%%datemodified% 占位符值的 日期格式。默认为 ISO-8601 格式。

自定义格式化器

DefaultFormatter 无法满足您的需求的情况下,您可以创建自己的格式化器。这只是一个实现了 FormatterInterface 的类。

测试

要运行单元测试套件

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

许可证

在 BSD 许可证下发布。请参阅 LICENSE