ruboty-japan_weather 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/ruboty/actions/japan_weather.rb +35 -2
- data/lib/ruboty/handlers/japan_weather.rb +5 -1
- data/lib/ruboty/japan_weather/version.rb +1 -1
- data/ruboty-japan_weather.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fb7d8c1459f77951f4d0aabaf2bc9ff7f43248c
|
4
|
+
data.tar.gz: 2613d0261cd0d6a75c5b143b61a762b8b15cee74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0827bdf0b025cdc742f28e73b26337e5c329cf72b04219eef97229b1610e5e866ca8cad8cbf3815c8e15a93b43ea911e6c7ad337c3ffc1af7e2cd49c1a4720a7
|
7
|
+
data.tar.gz: b5618a56a04747d523b585b3229832b3501eba5aada0e304ce6b8ec1ff964fb99c641883d17bca3891e6430af09e083f512ab27b4c843b4a61232d1c3d7d7160
|
data/README.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
#
|
2
|
-
An action to tell weather forecast for [
|
1
|
+
# Ruboty::JapanWeather
|
2
|
+
An action to tell weather forecast for [Ruboty](https://github.com/r7kamura/ruboty/) framework.
|
3
3
|
|
4
4
|
## Installation
|
5
5
|
```ruby
|
6
6
|
# Gemfile
|
7
|
-
gem '
|
7
|
+
gem 'ruboty-japan_weather'
|
8
8
|
```
|
9
9
|
|
10
10
|
## Usage
|
11
11
|
```
|
12
|
-
> @
|
12
|
+
> @ruboty 明日の秋葉原の天気教えて
|
13
13
|
東京都 千代田区の明日の天気は曇時々雨 最高気温25度 最低気温17度 降水確率は60% です。
|
14
|
-
> @
|
14
|
+
> @ruboty きょうのテヘランの天気は?
|
15
15
|
イラン テヘランの現在の天気は(17時00分 現在)晴時々曇 です。
|
16
16
|
```
|
@@ -8,14 +8,47 @@ module Ruboty
|
|
8
8
|
private
|
9
9
|
|
10
10
|
def forecast
|
11
|
-
|
11
|
+
if captures = cmd?(message.match_data.captures)
|
12
|
+
look_by_cmd(*captures).to_s
|
13
|
+
elsif body = jp?(message.match_data.captures)
|
14
|
+
look_by_jp(body).to_s
|
15
|
+
else
|
16
|
+
message.reply('Unmatched...')
|
17
|
+
end
|
12
18
|
end
|
13
19
|
|
14
|
-
def
|
20
|
+
def look_by_cmd(place, day)
|
21
|
+
WeatherJp.get(place, convert(day))
|
22
|
+
rescue WeatherJp::WeatherJpError => e
|
23
|
+
"Error: #{e}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def look_by_jp(body)
|
15
27
|
WeatherJp.parse(body)
|
16
28
|
rescue WeatherJp::WeatherJpError => e
|
17
29
|
"Error: #{e}"
|
18
30
|
end
|
31
|
+
|
32
|
+
def cmd?(captures)
|
33
|
+
captures[1..2] if captures[1] && captures[2]
|
34
|
+
end
|
35
|
+
|
36
|
+
def jp?(captures)
|
37
|
+
captures.first if captures.first
|
38
|
+
end
|
39
|
+
|
40
|
+
def convert(day)
|
41
|
+
case day
|
42
|
+
when /今日|きょう|今|いま/u
|
43
|
+
:today
|
44
|
+
when /明日|あした/u
|
45
|
+
:tomorrow
|
46
|
+
when /明後日|あさって/u
|
47
|
+
:day_after_tomorrow
|
48
|
+
else
|
49
|
+
day
|
50
|
+
end
|
51
|
+
end
|
19
52
|
end
|
20
53
|
end
|
21
54
|
end
|
@@ -1,7 +1,11 @@
|
|
1
1
|
module Ruboty
|
2
2
|
module Handlers
|
3
3
|
class JapanWeather < Base
|
4
|
-
on
|
4
|
+
on(
|
5
|
+
/((?<jp>.*の天気.*)|tenki\s+(?<place>.*)\s+(?<day>.*))/,
|
6
|
+
name: "japan_weather",
|
7
|
+
description: "Reply weather forecast"
|
8
|
+
)
|
5
9
|
|
6
10
|
def japan_weather(message)
|
7
11
|
Ruboty::Actions::JapanWeather.new(message).call
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-japan_weather
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taiki ONO
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: An action to tell weather forecast for ruboty bot framework.
|
70
84
|
email:
|
71
85
|
- taiks.4559@gmail.com
|