ruboty-hipchat 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4ac44b7c2e220159ac879ee33cb43a94f009a4f
4
+ data.tar.gz: 8f0ce0137d50c74a05066a6c414f2e8470add205
5
+ SHA512:
6
+ metadata.gz: 2673c131c4f19199af5692b2754bafbf985889bf5f6c849233eca9564ffc7ad2b1559fd35e0fbe6cff9d97b6123689f75eb4233056f2890ee868948edfcd29dd
7
+ data.tar.gz: ebba31344d5f00a0607e65e39055c162da474eb5f9ba2b88df8181abc3c1b86307db1ba2835752f1eabaf40056ac6e31c4b7434c464f3231c8e2d0fdc951359e
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,20 @@
1
+ ## 0.1.2
2
+ * Rename: Ellen -> Ruboty
3
+
4
+ ## 0.1.1
5
+ * Support Ruboty::Message#from_name
6
+
7
+ ## 0.1.0
8
+ * Change XMPP library: xmpp4r -> xrc
9
+
10
+ ## 0.0.4
11
+ * Support Ruboty v0.2.0
12
+
13
+ ## 0.0.3
14
+ * Set JID optional resource as "bot" to disable receiving chat-history :v:
15
+
16
+ ## 0.0.2
17
+ * Define dependent ENV variables
18
+
19
+ ## 0.0.1
20
+ * 1st release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruboty-hipchat.gemspec
4
+ gemspec
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,17 @@
1
+ # Ruboty::Hipchat
2
+ Hipchat adapter for [Ruboty](https://github.com/r7kamura/ruboty).
3
+
4
+ ## Usage
5
+ ```ruby
6
+ # Gemfile
7
+ gem "ruboty-hipchat"
8
+ ```
9
+
10
+ ## ENV
11
+ ```
12
+ HIPCHAT_DEBUG - Pass `1` to show debug information on stdout (optional)
13
+ HIPCHAT_JID - Account's JID (e.g. 12345_67890@chat.hipchat.com)
14
+ HIPCHAT_NICKNAME - Account's nickname, which must match the name on the HipChat account (e.g. Ruboty)
15
+ HIPCHAT_PASSWORD - Account's password (e.g. xxx)
16
+ HIPCHAT_ROOM_ID - Room ID the robot first logs in (e.g. 12345_room-name@conf.hipchat.com)
17
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,93 @@
1
+ require "xrc"
2
+
3
+ module Ruboty
4
+ module Adapters
5
+ class Hipchat < Base
6
+ include Mem
7
+
8
+ env :HIPCHAT_JID, "Account's JID (e.g. 12345_67890@chat.hipchat.com)"
9
+ env :HIPCHAT_NICKNAME, "Account's nickname, which must match the name on the HipChat account (e.g. ruboty)"
10
+ env :HIPCHAT_PASSWORD, "Account's password (e.g. xxx)"
11
+ env :HIPCHAT_ROOM_NAME, "Room name ruboty first logs in (e.g. 12345_myroom)"
12
+
13
+ def run
14
+ bind
15
+ connect
16
+ rescue Interrupt
17
+ exit
18
+ end
19
+
20
+ def say(message)
21
+ client.say(
22
+ body: message[:code] ? "/quote #{message[:body]}" : message[:body],
23
+ from: message[:from],
24
+ to: message[:original][:type] == "chat" ? message[:to] + "/resource" : message[:to],
25
+ type: message[:original][:type],
26
+ )
27
+ end
28
+
29
+ private
30
+
31
+ def client
32
+ @client ||= Xrc::Client.new(
33
+ jid: jid,
34
+ nickname: nickname,
35
+ password: password,
36
+ room_jid: room_jid,
37
+ )
38
+ end
39
+
40
+ private
41
+
42
+ def jid
43
+ jid = Xrc::Jid.new(ENV["HIPCHAT_JID"])
44
+ jid.resource = "bot"
45
+ jid.to_s
46
+ end
47
+
48
+ def room_jid
49
+ "#{room_name}@conf.hipchat.com"
50
+ end
51
+
52
+ def room_name
53
+ ENV["HIPCHAT_ROOM_NAME"]
54
+ end
55
+
56
+ def password
57
+ ENV["HIPCHAT_PASSWORD"]
58
+ end
59
+
60
+ def nickname
61
+ ENV["HIPCHAT_NICKNAME"]
62
+ end
63
+
64
+ def bind
65
+ client.on_private_message(&method(:on_message))
66
+ client.on_room_message(&method(:on_message))
67
+ end
68
+
69
+ def connect
70
+ client.connect
71
+ end
72
+
73
+ def on_message(message)
74
+ robot.receive(
75
+ body: message.body,
76
+ from: message.from,
77
+ from_name: username_of(message),
78
+ to: message.to,
79
+ type: message.type,
80
+ )
81
+ end
82
+
83
+ def username_of(message)
84
+ case message.type
85
+ when "groupchat"
86
+ Xrc::Jid.new(message.from).resource
87
+ else
88
+ client.users[message.from].name
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,5 @@
1
+ module Ruboty
2
+ module Hipchat
3
+ VERSION = "0.1.2"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "ruboty/adapters/hipchat"
2
+ require "ruboty/hipchat/version"
@@ -0,0 +1,23 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "ruboty/hipchat/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "ruboty-hipchat"
7
+ spec.version = Ruboty::Hipchat::VERSION
8
+ spec.authors = ["Ryo Nakamura"]
9
+ spec.email = ["r7kamura@gmail.com"]
10
+ spec.summary = "Hipchat adapter for Ruboty"
11
+ spec.homepage = "https://github.com/r7kamura/ruboty-hipchat"
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.5"
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-hipchat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
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.5
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.5
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/hipchat.rb
83
+ - lib/ruboty/hipchat.rb
84
+ - lib/ruboty/hipchat/version.rb
85
+ - ruboty-hipchat.gemspec
86
+ homepage: https://github.com/r7kamura/ruboty-hipchat
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: Hipchat adapter for Ruboty
110
+ test_files: []
111
+ has_rdoc: