cornford/pokenotifier
Composer 安装命令:
composer require cornford/pokenotifier
包简介
An easy way to send nearby Pokemon notifications to Slack.
README 文档
README
Think of Pokenotifier as an easy way to generate Slack notifications for nearby Pokemon using PokemonGo-Map. These include:
processScanRequestprocessWebhookRequestrequestPokemonGoMapScanrequestPokemonGoMapDataexpireCachedItemssendSlackNotificationprocessPokemonloadApplicationConfigurationgetApplicationConfigurationloadPokemonConfigurationgetPokemonConfigurationcreateGuzzleClientgetGuzzleClientsetGuzzleClientcreateSlackClientgetSlackClientsetSlackClientcreateDirectoryIteratorInstancegetDirectoryIteratorInstancesetDirectoryIteratorInstance
Installation
Begin by installing this package through Composer. Edit your project's composer.json file to require cornford/pokenotifier.
"require": {
"cornford/pokenotifier": "1.*"
}
Next, update Composer from the Terminal:
composer update
Finally we need to introduce the configuration files into your application/
cp src/config/{example.,}application.php
That's it! You're all set to go.
Configuration
You can now configure Pokenotifier in a few simple steps. Open src/config/application.php and update the options as needed.
default-latitude- Default latitude used for scan.default-longitude- Default longitude used for scan.cache-directory- Cache directory location.pokemongo-protocol- The protocol of the PokemonGo-Map server.pokemongo-ip- The IP address of the PokemonGo-Map server.pokemongo-port- The port of the PokemonGo-Map server.pokemon-rarity- The Pokemon level of rarity to notify, etc (1-5).slack-webhook- The URL of the Slack server webhook.slack-channel- The channel of the Slack server.
Usage
It's really as simple as using the Pokenotifier class in any Controller / Model / File you see fit with:
$notifier = new Cornford\Pokenotifier\Notifier();
This will give you access to
- Process Scan Request
- Process Webhook Request
- Request Pokemon Go Map Scan
- Request Pokemon Go Map Data
- Expire Cached Items
- Send Slack Notification
- Process Pokemon
- Load Application Configuration
- Get Application Configuration
- Load Pokemon Configuration
- Get Pokemon Configuration
- Create Guzzle Client
- Get Guzzle Client
- Set Guzzle Client
- Create Slack Client
- Get Slack Client
- Set Slack Client
- Create Directory Iterator
- Get Directory Iterator
- Set Directory Iterator
Process Scan Request
The processScanRequest method allows you to process a scan request, using a position object as a parameter.
$notifier->processScanRequest(new Cornford\Pokenotifier\Models\Position(0, 0));
Process Scan Request
The processWebhookRequest method allows you to process a webhook request, using a position object, and request data as parameters.
$notifier->processWebhookRequest(new Cornford\Pokenotifier\Models\Position(0, 0), ['pokemons'=> []]);
Request Pokemon Go Map Scan
The requestPokemonGoMapScan method allows you to send a scan request to PokemonGo-Map, using a position object as a parameter.
$notifier->requestPokemonGoMapScan(new Cornford\Pokenotifier\Models\Position(0, 0));
Request Pokemon Go Map Data
The requestPokemonGoMapData method allows you to send a data request to PokemonGo-Map.
$notifier->requestPokemonGoMapData();
Expire Cached Items
The expireCachedItems method allows you to expire cached items that haven't been modified for a specified timeout, using a string as a parameter.
$notifier->expireCachedItems('-1 day');
Send Slack Notification
The sendSlackNotification method allows you to send a Slack notification, using an array of Pokemon data, and a position object as parameters.
$notifier->sendSlackNotification(['pokemon_id' => '', 'pokemon_name' => '', 'latitude' => '', 'longitude' => '', 'disappear_time' => ''], new Cornford\Pokenotifier\Models\Position(0, 0));
Process Pokemon
The processPokemon method allows you to process an array of Pokemon's and optionally send a Slack notificaiton, using an array of Pokemon data, a position object, and a boolean for notification as parameters.
$notifier->processPokemon(['pokemons'=> []], new Cornford\Pokenotifier\Models\Position(0, 0), true);
Load Application Configuration
The loadApplicationConfiguration method allows you to load the current application configuration file.
$notifier->loadApplicationConfiguration();
Get Application Configuration
The getApplicationConfiguration method allows you to get the currently stored application configuration.
$notifier->getApplicationConfiguration();
Load Pokemon Configuration
The loadPokemonConfiguration method allows you to load the current Pokemon configuration file.
$notifier->loadPokemonConfiguration();
Get Pokemon Configuration
The getPokemonConfiguration method allows you to get the currently stored Pokemon configuration.
$notifier->getPokemonConfiguration();
Create Guzzle Client
The createGuzzleClient method allows you to instantiate a new Guzzle Client.
$notifier->createGuzzleClient();
Get Guzzle Client
The getGuzzleClient method allows you to get the currently instantiated Guzzle Client.
$notifier->getGuzzleClient();
Set Guzzle Client
The setGuzzleClient method allows you to store a new instantiation of Guzzle Client, using a client object as a parameter.
$notifier->setGuzzleClient(new GuzzleClient(['base_url' => 'http://www.google.com']));
Create Slack Client
The createSlackClient method allows you to instantiate a new Slack Client.
$notifier->createSlackClient();
Get Slack Client
The getSlackClient method allows you to get the currently instantiated Slack Client.
$notifier->getSlackClient();
Set Slack Client
The setSlackClient method allows you to store a new instantiation of Slack Client, using a client object as a parameter.
$notifier->setSlackClient(new SlackClient('https://hooks.slack.com/services/', [], $notifier->getGuzzleClient()));
Create Directory Iterator
The createDirectoryIterator method allows you to instantiate a new Directory Iterator.
$notifier->createDirectoryIterator();
Get Directory Iterator
The getDirectoryIterator method allows you to get the currently instantiated Directory Iterator.
$notifier->getDirectoryIterator();
Set Directory Iterator
The setDirectoryIterator method allows you to store a new instantiation of Directory Iterator, using a iterator object as a parameter.
$notifier->setDirectoryIterator('./cache');
Example
For an example usage see index.php
Webhook
You can run a webhook with PokemonGo-Map with the following command, where the -wh parameter is the location where the script is located. You can run a local webserver, listening locally to respond to webhook request.
sudo python /var/www/PokemonGo-Map/runserver.py -wh http://localhost?type=webhook
Scan
You can run a scan with PokemonGo-Map with the following command, where the post data contains both lat and lon parameters. You can run an application like Traccar Client, to send requests to your webserver for scan.
curl --data "lat=53.3811&lon=-1.4701" http://localhost?type=scan
License
Pokenotifier is open-sourced software licensed under the MIT license
cornford/pokenotifier 适用场景与选型建议
cornford/pokenotifier 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 07 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「map」 「notification」 「slack」 「pokemon」 「nearby」 「pokemon go」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cornford/pokenotifier 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cornford/pokenotifier 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cornford/pokenotifier 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Maps in minutes. Powered by the Google Maps API.
Yii2 map input widget. Allows you to select geographcal coordinates via a human-friendly inteface.
This package makes it easy to send notifications via AfricasTalking with Laravel
A Highly Opinionated Symfony3/4 Deployer Recipe
Apple Push Notification & Feedback Provider
This bundle provides integration with the Slack API library, allowing you to interact with the Slack API from within your Symfony projects
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-29