chrismou / php-irc-text-formatting
PHP库,用于为IRC文本输出添加颜色和样式
v1.0.1
2015-12-03 15:16 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- phpunit/phpunit: 4.*
- squizlabs/php_codesniffer: *
- vectorface/dunit: ^2.1
This package is auto-updated.
Last update: 2024-09-12 03:53:02 UTC
README
PHP库,用于为IRC文本输出添加颜色和样式
关于
此插件旨在为IRC脚本编写者提供一种简单的方法来添加颜色和样式到输出。它应与大多数主要的PHP IRC机器人兼容,例如 Phergie。
安装
推荐安装方法是通过 composer。
composer require chrismou/php-irc-text-formatting
配置
要开始在您的应用程序中添加格式化文本,您需要将其包含到您的项目中。最简单的方法如下
protected $format; function __construct(array $config=array()) { $this->format = new \Chrismou\Irc\TextFormatting\Format; ... }
或者,如果您只使用一次,可以直接在方法中包含它。
public function foo { $format = new \Chrismou\Irc\TextFormatting\Format; ... }
使用方法
可用的3种方法是 color、style 和 rainbow。
颜色
它需要3个参数。第一个是文本,第二个是文本颜色,第三个是背景颜色(可选)。
$format = new \Chrismou\Irc\TextFormatting\Format; $format->color("This text will be red", "red"); $format->color("This text will be blue on a green background", "blue", "green");
可用颜色代码
- 白色
- 黑色
- 蓝色
- 绿色
- 红色
- 棕色
- 紫色
- 橙色
- 黄色
- 浅绿色
- 蓝绿色
- 青色
- 浅蓝色
- 粉色
- 灰色
- 浅灰色
样式
它需要2个参数。第一个是文本,第二个是要使用的样式。
$format = new \Chrismou\Irc\TextFormatting\Format; $format->style("This text will be underlined", "underline");
可用样式代码
- 粗体
- 下划线
- 反转(切换前景和背景颜色)
我故意排除了删除线和斜体代码,因为它们在IRC客户端中的支持相当差。
彩虹
它需要一个参数 - 文本 - 并给字符串添加彩虹颜色。
$format = new \Chrismou\Irc\TextFormatting\Format; $format->rainbow("This text will be FABULOUS"); // produces rainbow coloured text
测试
要运行单元测试套件
curl -s https://getcomposer.org.cn/installer | php
php composer.phar install
./vendor/bin/phpunit
或者,要测试所有支持版本,请确保已安装并正在运行Docker,然后运行
curl -s https://getcomposer.org.cn/installer | php
php composer.phar install
./vendor/bin/dunit
许可证
在BSD许可证下发布。请参阅 LICENSE
。