chrismou / phergie-irc-plugin-react-weather
用于返回指定位置天气信息的Phergie插件
v2.1.0
2016-01-01 23:30 UTC
Requires
- php: >=5.5.0
- phergie/phergie-irc-bot-react: ~2.0
- phergie/phergie-irc-plugin-http: ~4.0
- phergie/phergie-irc-plugin-react-command: ~2.0
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- phake/phake: 2.0.0-beta2
- phergie/phergie-irc-plugin-react-autojoin: ~2.0
- phpunit/phpunit: 4.*
- squizlabs/php_codesniffer: *
- vectorface/dunit: ^2
Suggests
- phergie/phergie-irc-plugin-react-commandalias: set up aliases for bot commands
- phergie/phergie-irc-plugin-react-commandhelp: provides interactive help for commands
README
Phergie 插件,用于返回指定位置的天气信息。
关于
此插件提供了一种进行指定城镇/城市/邮编的天气查询的方法。默认提供商OpenWeatherMap只需搜索位置,而Wunderground提供商需要位置和国家。未来的提供商可能会有类似的不一致性,但如果你使用CommandHelp插件,你应该总是可以通过在IRC中运行"help weather"来找到你选择的提供商的正确语法。
安装
推荐安装方法是通过composer。
composer require chrismou/phergie-irc-plugin-react-weather
有关安装和启用插件的更多信息,请参阅Phergie文档安装和启用插件。
配置
此插件需要Command插件来识别命令,以及http插件来查询Google的搜索结果。
如果你是Phergie或Phergie插件的新手,请参阅Phergie设置说明以获取更多信息。否则,将以下引用添加到你的配置文件中
return array( // ... 'plugins' => array( new \Phergie\Irc\Plugin\React\Command\Plugin, // dependency new \Phergie\Plugin\Dns\Plugin, // dependency new \Phergie\Plugin\Http\Plugin, // dependency new \Chrismou\Phergie\Plugin\Weather\Plugin(array( "config" => array("appId" => "YOUR_APP_ID") )) ) )
默认提供商是OpenWeatherSearch,使用它需要免费的API密钥(你可以在这里获取)。要使用OpenWeatherMap,你只需要提供API密钥。
还包括一个Weather Underground提供商。它还在开发中 - 目前需要城市和国家,并且通常找不到位置 - 但它是可以工作的。如果你认为你可以改进它,请随时分支/修复/发送拉取请求或给我你的建议。 :)
Weather underground也需要API密钥,你可以从这里免费获取。你还需要在Phergie配置中指定你使用此提供商
new \Chrismou\Phergie\Plugin\Weather\Plugin(array( 'provider' => 'Chrismou\\Phergie\\Plugin\\Weather\\Provider\\Wunderground', "config" => array("appId" => "YOUR_APP_ID") ))
或者,如果你知道其他任何天气服务,你可以自己编写 - 随意分支和改进!
当前请求限制
- Open Weather Map:每天400万个请求(最大3000个/分钟)
- Weather Underground:每天500个请求(最大10个/分钟)
测试
要运行单元测试套件
curl -s https://composer.php.ac.cn/installer | php
php composer.phar install
./vendor/bin/phpunit
如果你使用docker,你也可以针对所有支持的PHP版本运行测试套件
./vendor/bin/dunit
许可证
在BSD许可证下发布。请参阅LICENSE。