Huginnで天気予報をSlackに通知
Huginn。
Weather Agentでdarkskyとかwundergroundから取ってくるのもいいけど、特に登録も必要なくて楽なんでLivedoorのお天気Webサービスを使う。
Website Agent
Scheduleは通知させたい時間を選択。
{ "expected_update_period_in_days": "2", "url": "http://weather.livedoor.com/forecast/webservice/json/v1?city=1次細分区コード", "type": "json", "mode": "all", "extract": { "date": {"path": "forecasts[0].date"}, "location": {"path": "location.city"}, "weather": {"path": "forecasts[0].telop"}, "icon": {"path": "forecasts[0].image.url"}, "highest": {"path": "forecasts[0].temperature.max.celsius"}, "lowest": {"path": "forecasts[0].temperature.min.celsius"}, "description": {"path": "description.text"}, "link": {"path": "link"} } }
Slack Agent
SoucesにさっきのWebsite Agentを選択してPropagate immediatelにチェック。
{ "webhook_url": "各々", "channel": "各々", "username": "各々", "icon": "各々", "message": "{{date | date: '%Y年%m月%d日' }}の天気は{{weather}}\n最高気温/最低気温 : {{highest}}℃/{{lowest}}℃\n\n{{description | replace: '\n', '' }}\n\n<{{link}}|Livedoor天気情報 - {{location}}>", "attachments": [ {"image_url": "{{icon}}"} ] }
おわり
こんなん。