ruboty-slack 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/CHANGELOG.md +26 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +18 -0
- data/Rakefile +2 -0
- data/lib/ruboty/adapters/slack.rb +97 -0
- data/lib/ruboty/slack.rb +2 -0
- data/lib/ruboty/slack/version.rb +5 -0
- data/ruboty-slack.gemspec +23 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aaf8070203e92e23b7900223031ad622d31793ea
|
4
|
+
data.tar.gz: af306fd9c775da8a80e0782111cf744b0b822984
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 05ea6ae2902dcd6ef0b493a494539fdf5556ba5eb294ef68302b29ad430ae6556cb72df1491f36aab7e50992b8b5f7e1f722d530efeddb8d15cbcc074a6804cf
|
7
|
+
data.tar.gz: 53ea94c5991bcc35569027b03ebaa38a1ff57ef6ee770267c0e464ada06918dabe1c07902c2393308eace38e10675779cd265bfff9e3621d868756a8bd5d6678
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
## 0.1.4
|
2
|
+
* Rename: Ellen -> Ruboty
|
3
|
+
|
4
|
+
## 0.1.3
|
5
|
+
* Support Ruboty::Message#from_name
|
6
|
+
|
7
|
+
## 0.1.2
|
8
|
+
* Format message body if :code option is passed
|
9
|
+
|
10
|
+
## 0.1.1
|
11
|
+
* Fix private message handler
|
12
|
+
|
13
|
+
## 0.1.0
|
14
|
+
* Use XMPP Gateway instead of IRC
|
15
|
+
|
16
|
+
## 0.0.4
|
17
|
+
* Support Ruboty v0.2.0
|
18
|
+
|
19
|
+
## 0.0.3
|
20
|
+
* Support multiline message
|
21
|
+
|
22
|
+
## 0.0.2
|
23
|
+
* Fix encoding problem (forced to UTF-8)
|
24
|
+
|
25
|
+
## 0.0.1
|
26
|
+
* 1st Release
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ryo Nakamura
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Ruboty::Slack
|
2
|
+
Slack adapter for [Ruboty](https://github.com/r7kamura/ruboty).
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
See https://my.slack.com/admin/settings to enable XMPP Gateway on Slack.
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
# Gemfile
|
9
|
+
gem "ruboty-slack"
|
10
|
+
```
|
11
|
+
|
12
|
+
## ENV
|
13
|
+
```
|
14
|
+
SLACK_PASSWORD - Account's XMPP password
|
15
|
+
SLACK_ROOM - Room name to join in at first (e.g. general)
|
16
|
+
SLACK_TEAM - Account's team name (e.g. wonderland)
|
17
|
+
SLACK_USERNAME - Account's username (e.g. alice)
|
18
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
require "xrc"
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module Adapters
|
5
|
+
class Slack < Base
|
6
|
+
env :SLACK_PASSWORD, "Account's XMPP password (See https://tqhouse.slack.com/account/gateways)"
|
7
|
+
env :SLACK_ROOM, "Room name to join in at first (e.g. general)"
|
8
|
+
env :SLACK_TEAM, "Account's team name (e.g. wonderland)"
|
9
|
+
env :SLACK_USERNAME, "Account's username (e.g. alice)"
|
10
|
+
|
11
|
+
def run
|
12
|
+
bind
|
13
|
+
connect
|
14
|
+
end
|
15
|
+
|
16
|
+
def say(message)
|
17
|
+
client.say(
|
18
|
+
body: message[:code] ? "```\n#{message[:body]}\n```" : message[:body],
|
19
|
+
from: message[:from],
|
20
|
+
to: message[:original][:type] == "chat" ? message[:to] + "/resource" : message[:to],
|
21
|
+
type: message[:original][:type],
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def client
|
28
|
+
@client ||= Xrc::Client.new(
|
29
|
+
jid: jid,
|
30
|
+
nickname: username,
|
31
|
+
password: password,
|
32
|
+
room_jid: room_jid,
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def jid
|
37
|
+
"#{username}@#{host}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def room_jid
|
41
|
+
"#{room}@#{room_host}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def host
|
45
|
+
"#{team}.xmpp.slack.com"
|
46
|
+
end
|
47
|
+
|
48
|
+
def room_host
|
49
|
+
"conference.#{host}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def room
|
53
|
+
ENV["SLACK_ROOM"]
|
54
|
+
end
|
55
|
+
|
56
|
+
def username
|
57
|
+
ENV["SLACK_USERNAME"]
|
58
|
+
end
|
59
|
+
|
60
|
+
def password
|
61
|
+
ENV["SLACK_PASSWORD"]
|
62
|
+
end
|
63
|
+
|
64
|
+
def team
|
65
|
+
ENV["SLACK_TEAM"]
|
66
|
+
end
|
67
|
+
|
68
|
+
def bind
|
69
|
+
client.on_private_message(&method(:on_message))
|
70
|
+
client.on_room_message(&method(:on_message))
|
71
|
+
end
|
72
|
+
|
73
|
+
def connect
|
74
|
+
client.connect
|
75
|
+
end
|
76
|
+
|
77
|
+
def on_message(message)
|
78
|
+
robot.receive(
|
79
|
+
body: message.body,
|
80
|
+
from: message.from,
|
81
|
+
from_name: username_of(message),
|
82
|
+
to: message.to,
|
83
|
+
type: message.type,
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
def username_of(message)
|
88
|
+
case message.type
|
89
|
+
when "groupchat"
|
90
|
+
Xrc::Jid.new(message.from).resource
|
91
|
+
else
|
92
|
+
Xrc::Jid.new(message.from).node
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/lib/ruboty/slack.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "ruboty/slack/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ruboty-slack"
|
7
|
+
spec.version = Ruboty::Slack::VERSION
|
8
|
+
spec.authors = ["Ryo Nakamura"]
|
9
|
+
spec.email = ["r7kamura@gmail.com"]
|
10
|
+
spec.summary = "Slack adapter for Ruboty."
|
11
|
+
spec.homepage = "https://github.com/r7kamura/ruboty-slack"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0")
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "ruboty"
|
20
|
+
spec.add_dependency "xrc", ">= 0.0.3"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-slack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryo Nakamura
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-31 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: xrc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- r7kamura@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- CHANGELOG.md
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/ruboty/adapters/slack.rb
|
83
|
+
- lib/ruboty/slack.rb
|
84
|
+
- lib/ruboty/slack/version.rb
|
85
|
+
- ruboty-slack.gemspec
|
86
|
+
homepage: https://github.com/r7kamura/ruboty-slack
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.2.2
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Slack adapter for Ruboty.
|
110
|
+
test_files: []
|
111
|
+
has_rdoc:
|