ruboty-haiku_wo_yome 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.md +14 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/lib/ruboty/haiku_wo_yome/actions/haiku.rb +50 -0
- data/lib/ruboty/haiku_wo_yome/version.rb +5 -0
- data/lib/ruboty/haiku_wo_yome.rb +11 -0
- data/lib/ruboty/handlers/haiku.rb +15 -0
- data/ruboty-haiku_wo_yome.gemspec +28 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5549915fe7b0bbb279cb62747da83f93879a3b94
|
4
|
+
data.tar.gz: 66d142fd12d52014e097dfc1d0e195942971015c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e299c9e92d6af5e46c18be34c8c917394b0f54556a4105358e0a9e3bf32ef5c56419c10343b364ecd134dfedbc94e8e1ca53dfe105b7e4959b25c78ae9ff20c6
|
7
|
+
data.tar.gz: f6cc26c622f4ee4ca8fc33a3c0da016cc703bc4dd121c3106aaab09e1595ad3d46f532a4efcefb531ff17b7d06f8b766bd4a51c2223fed501f9466102ee2b34b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
2
|
+
Version 2, December 2004
|
3
|
+
|
4
|
+
Copyright (C) 2015 Yasuhiro Kinoshita <WhoIsDissolvedGirl+github@gmail.com>
|
5
|
+
|
6
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
7
|
+
copies of this license document, and changing it is allowed as long
|
8
|
+
as the name is changed.
|
9
|
+
|
10
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
11
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
12
|
+
|
13
|
+
0. You just DO WHAT THE FUCK YOU WANT TO.
|
14
|
+
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Ruboty::HaikuWoYome
|
2
|
+
|
3
|
+
ハイクを詠め、カイシャクしてやる
|
4
|
+
|
5
|
+
## Caution!!!
|
6
|
+
|
7
|
+
This gem is work on Slack ONLY !!!!!!!!!!!!!!!!!!
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Write this in your Ruboty Gemfile
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'ruboty-haiku_wo_yome'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```
|
24
|
+
@kinoppyd: ハイクを読め
|
25
|
+
すいません今日は早めに帰宅して
|
26
|
+
```
|
27
|
+
|
28
|
+
## LICENSE
|
29
|
+
|
30
|
+
WTFPL
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
35
|
+
|
36
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruboty-haiku_wo_yome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
41
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module HaikuWoYome
|
3
|
+
module Actions
|
4
|
+
class Haiku < Ruboty::Actions::Base
|
5
|
+
def call
|
6
|
+
haiku = haiku_list.sample || '「アイエエエエ!?」'
|
7
|
+
message.reply(haiku)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def client
|
13
|
+
@client ||= Slack.client(token: ENV['SLACK_TOKEN'])
|
14
|
+
end
|
15
|
+
|
16
|
+
def haiku_list
|
17
|
+
haiku_nodes = user_public_messages_text.inject([]) do |acc, message|
|
18
|
+
haiku = haiku_reviewer.search(message)
|
19
|
+
acc + haiku
|
20
|
+
end
|
21
|
+
|
22
|
+
haiku_nodes.map do |haiku_node|
|
23
|
+
haiku_node.phrases.join
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def user_public_messages_text
|
28
|
+
user_public_messages.select { |m| m['type'] != 'group' }.map { |t| t['text'] }
|
29
|
+
end
|
30
|
+
|
31
|
+
def user_public_messages
|
32
|
+
search_result = client.search_messages(query: user_name, count: 1000)
|
33
|
+
return [] if search_result.nil?
|
34
|
+
return [] if search_result['messages'].nil?
|
35
|
+
search_result['messages']['matches']
|
36
|
+
end
|
37
|
+
|
38
|
+
def user_name
|
39
|
+
name = message[:user_name]
|
40
|
+
name = name.gsub(':', '')
|
41
|
+
name.start_with?('@') ? name : "@#{name}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def haiku_reviewer
|
45
|
+
@reviewer ||= Ikku::Reviewer.new
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'ruboty/haiku_wo_yome/actions/haiku'
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module Handlers
|
5
|
+
class Haiku < Ruboty::Handlers::Base
|
6
|
+
env 'SLACK_TOKEN', 'Slack token'
|
7
|
+
|
8
|
+
on('(?<user_name>.+) ハイクを詠め', name: :haiku_wo_yome, description: 'カイシャクしてやる', all: true)
|
9
|
+
|
10
|
+
def haiku_wo_yome(message)
|
11
|
+
Ruboty::HaikuWoYome::Actions::Haiku.new(message).call
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruboty/haiku_wo_yome/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruboty-haiku_wo_yome"
|
8
|
+
spec.version = Ruboty::HaikuWoYome::VERSION
|
9
|
+
spec.authors = ["Kinoshita.Yasuhiro"]
|
10
|
+
spec.email = ["WhoIsDissolvedGirl+github@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Haiku wo yome, kaisyaku shite yaru}
|
13
|
+
spec.description = %q{Search users message from Slack and find haiku}
|
14
|
+
spec.homepage = "https://github.com/YasuhiroKinoshita/ruboty-haiku_wo_yome"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
spec.license = 'WTFPL'
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "ruboty", "~> 1.2"
|
22
|
+
spec.add_runtime_dependency "ikku", "~> 0.1"
|
23
|
+
spec.add_runtime_dependency "slack-api", "~> 1.1"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "wtfpl_init"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-haiku_wo_yome
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kinoshita.Yasuhiro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruboty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ikku
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: slack-api
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: wtfpl_init
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Search users message from Slack and find haiku
|
112
|
+
email:
|
113
|
+
- WhoIsDissolvedGirl+github@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".travis.yml"
|
121
|
+
- CODE_OF_CONDUCT.md
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.md
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- lib/ruboty/haiku_wo_yome.rb
|
127
|
+
- lib/ruboty/haiku_wo_yome/actions/haiku.rb
|
128
|
+
- lib/ruboty/haiku_wo_yome/version.rb
|
129
|
+
- lib/ruboty/handlers/haiku.rb
|
130
|
+
- ruboty-haiku_wo_yome.gemspec
|
131
|
+
homepage: https://github.com/YasuhiroKinoshita/ruboty-haiku_wo_yome
|
132
|
+
licenses:
|
133
|
+
- WTFPL
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.4.5
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: Haiku wo yome, kaisyaku shite yaru
|
155
|
+
test_files: []
|