ruboty-haiku_wo_yome 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/ruboty/haiku_wo_yome/actions/haiku.rb +41 -9
- data/lib/ruboty/haiku_wo_yome/version.rb +1 -1
- data/lib/ruboty/handlers/haiku.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfd5cdc5131804509972eeca5985b87d139c2a16
|
4
|
+
data.tar.gz: c121133f8f556e5e1ec55f7127f079f1fbc7a786
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f57c3c69ed8c3a27d89fb6927b0b96acb65e1ed7a48ff204123b5f6a370e9be42e91c461a9a578a2c004a6a9c7bdd8ac7125de7d068e8f117e653fbe942624a
|
7
|
+
data.tar.gz: 258af8ee6e11d39a75105be8d3e0b792f8838d919835cfe62ea3977706dca31f9e0e130d95f70422a6aace8a697d02a99017c38282199c240bb63de84c0f9b0e
|
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,14 @@ module Ruboty
|
|
2
2
|
module HaikuWoYome
|
3
3
|
module Actions
|
4
4
|
class Haiku < Ruboty::Actions::Base
|
5
|
-
def call
|
6
|
-
|
5
|
+
def call(options = {type: :haiku})
|
6
|
+
list = case options[:type]
|
7
|
+
when :tanka
|
8
|
+
tanka_list
|
9
|
+
else
|
10
|
+
haiku_list
|
11
|
+
end
|
12
|
+
haiku = list.sample || '「アイエエエエ!?」'
|
7
13
|
message.reply(haiku)
|
8
14
|
end
|
9
15
|
|
@@ -14,13 +20,34 @@ module Ruboty
|
|
14
20
|
end
|
15
21
|
|
16
22
|
def haiku_list
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
user_public_messages_text.inject([]) do |acc, message|
|
24
|
+
haiku_reviewer.search(message).each do |node|
|
25
|
+
acc << node.phrases.join
|
26
|
+
end
|
27
|
+
acc
|
20
28
|
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def tanka_list
|
32
|
+
kaminoku_nodes = user_public_messages_text.inject([]) do |acc, message|
|
33
|
+
haiku_reviewer.search(message).each do |node|
|
34
|
+
acc << node.phrases.join
|
35
|
+
end
|
36
|
+
acc
|
37
|
+
end
|
38
|
+
|
39
|
+
reset!
|
40
|
+
shimonoku_nodes = user_public_messages_text.inject([]) do |acc, message|
|
41
|
+
haiku_reviewer(rule: [7, 7]).search(message).each do |node|
|
42
|
+
acc << node.phrases.join
|
43
|
+
end
|
44
|
+
acc
|
45
|
+
end
|
46
|
+
|
47
|
+
return [] if shimonoku_nodes.empty?
|
21
48
|
|
22
|
-
|
23
|
-
|
49
|
+
kaminoku_nodes.map do |kaminoku|
|
50
|
+
"#{kaminoku} #{shimonoku_nodes.sample}"
|
24
51
|
end
|
25
52
|
end
|
26
53
|
|
@@ -41,8 +68,13 @@ module Ruboty
|
|
41
68
|
name.start_with?('@') ? name : "@#{name}"
|
42
69
|
end
|
43
70
|
|
44
|
-
def haiku_reviewer
|
45
|
-
|
71
|
+
def haiku_reviewer(options = {})
|
72
|
+
rule = options[:rule] || [5, 7, 5]
|
73
|
+
@reviewer ||= Ikku::Reviewer.new(rule: rule)
|
74
|
+
end
|
75
|
+
|
76
|
+
def reset!
|
77
|
+
@reviewer = nil
|
46
78
|
end
|
47
79
|
end
|
48
80
|
end
|
@@ -6,10 +6,15 @@ module Ruboty
|
|
6
6
|
env 'SLACK_TOKEN_FOR_SEARCH', "Slack token for search api (important: bot user can't call search api! require human api key"
|
7
7
|
|
8
8
|
on('(?<user_name>.+) ハイクを詠め', name: :haiku_wo_yome, description: 'カイシャクしてやる', all: true)
|
9
|
+
on('(?<user_name>.+) タンカを詠め', name: :tanka_wo_yome, description: 'カイシャクしてやる', all: true)
|
9
10
|
|
10
11
|
def haiku_wo_yome(message)
|
11
12
|
Ruboty::HaikuWoYome::Actions::Haiku.new(message).call
|
12
13
|
end
|
14
|
+
|
15
|
+
def tanka_wo_yome(message)
|
16
|
+
Ruboty::HaikuWoYome::Actions::Haiku.new(message).call(type: :tanka)
|
17
|
+
end
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-haiku_wo_yome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kinoshita.Yasuhiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|