hipbot 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +3 -3
- data/Gemfile +12 -1
- data/README.md +16 -8
- data/bin/hipbot +5 -0
- data/hipbot.gemspec +2 -1
- data/lib/hipbot.rb +7 -10
- data/lib/hipbot/adaptable.rb +60 -0
- data/lib/hipbot/adapter.rb +6 -6
- data/lib/hipbot/adapters/hipchat.rb +5 -48
- data/lib/hipbot/adapters/hipchat/client.rb +8 -0
- data/lib/hipbot/adapters/shell.rb +2 -9
- data/lib/hipbot/adapters/slack.rb +10 -0
- data/lib/hipbot/adapters/slack/client.rb +47 -0
- data/lib/hipbot/adapters/telnet.rb +2 -9
- data/lib/hipbot/adapters/xmpp.rb +59 -0
- data/lib/hipbot/adapters/{hipchat/initializer.rb → xmpp/client.rb} +35 -21
- data/lib/hipbot/bot.rb +5 -1
- data/lib/hipbot/callbacks/base.rb +20 -2
- data/lib/hipbot/callbacks/lobby_presence.rb +2 -1
- data/lib/hipbot/callbacks/presence.rb +1 -5
- data/lib/hipbot/callbacks/room_invite.rb +13 -0
- data/lib/hipbot/callbacks/room_message.rb +3 -9
- data/lib/hipbot/callbacks/room_presence.rb +10 -8
- data/lib/hipbot/callbacks/room_topic.rb +18 -0
- data/lib/hipbot/configuration.rb +11 -6
- data/lib/hipbot/helpers.rb +2 -0
- data/lib/hipbot/{http.rb → helpers/http.rb} +11 -7
- data/lib/hipbot/message.rb +2 -2
- data/lib/hipbot/presence.rb +0 -6
- data/lib/hipbot/reaction.rb +9 -7
- data/lib/hipbot/response.rb +1 -1
- data/lib/hipbot/room.rb +1 -1
- data/lib/hipbot/storages/hash.rb +5 -5
- data/lib/hipbot/storages/mongoid.rb +1 -1
- data/lib/hipbot/user.rb +4 -0
- data/lib/hipbot/{cache.rb → utilities/cache.rb} +0 -0
- data/lib/hipbot/{logger.rb → utilities/logger.rb} +0 -0
- data/lib/hipbot/version.rb +1 -1
- data/spec/integration/my_hipbot_spec.rb +1 -1
- data/spec/spec_helper.rb +7 -2
- data/spec/unit/match_spec.rb +7 -7
- data/spec/unit/message_spec.rb +2 -2
- data/spec/unit/reaction_spec.rb +14 -14
- metadata +28 -8
- data/lib/hipbot/callbacks/invite.rb +0 -11
data/lib/hipbot/reaction.rb
CHANGED
@@ -34,10 +34,6 @@ module Hipbot
|
|
34
34
|
!!options[:global]
|
35
35
|
end
|
36
36
|
|
37
|
-
def inspect
|
38
|
-
"#<Hipbot::Reaction #{options}>"
|
39
|
-
end
|
40
|
-
|
41
37
|
def plugin_name
|
42
38
|
plugin.name.demodulize
|
43
39
|
end
|
@@ -53,10 +49,16 @@ module Hipbot
|
|
53
49
|
attr_cache :readable_command do
|
54
50
|
regexps.map(&:source).join(' or ').gsub(/\^|\\z|\$|\\/, '')
|
55
51
|
end
|
52
|
+
delegate :to_s, to: :readable_command
|
56
53
|
|
57
54
|
attr_cache :regexps do
|
58
|
-
Array(options[:regexps])
|
59
|
-
|
55
|
+
regexps = Array(options[:regexps])
|
56
|
+
if Hipbot.configuration.case_insensitive
|
57
|
+
regexps.map do |regexp|
|
58
|
+
Regexp.new(regexp.source, Regexp::IGNORECASE)
|
59
|
+
end
|
60
|
+
else
|
61
|
+
regexps
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
@@ -71,7 +73,7 @@ module Hipbot
|
|
71
73
|
protected
|
72
74
|
|
73
75
|
def replace_symbols values, replacements_hash
|
74
|
-
Array(values).flat_map{ |v| replacements_hash[v] || v }.
|
76
|
+
Array(values).flat_map{ |v| replacements_hash[v] || v }.uniq
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
data/lib/hipbot/response.rb
CHANGED
data/lib/hipbot/room.rb
CHANGED
data/lib/hipbot/storages/hash.rb
CHANGED
@@ -77,12 +77,12 @@ module Hipbot
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
protected
|
80
|
+
# protected
|
81
81
|
|
82
|
-
def method_missing name, *args, &block
|
83
|
-
|
84
|
-
|
85
|
-
end
|
82
|
+
# def method_missing name, *args, &block
|
83
|
+
# return all.public_send(name, *args, &block) if Array.instance_methods.include?(name)
|
84
|
+
# super
|
85
|
+
# end
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
data/lib/hipbot/user.rb
CHANGED
File without changes
|
File without changes
|
data/lib/hipbot/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/unit/match_spec.rb
CHANGED
@@ -24,7 +24,7 @@ describe Hipbot::Match do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#matches?" do
|
27
|
-
its(:matches?) { should
|
27
|
+
its(:matches?) { should be_truthy }
|
28
28
|
|
29
29
|
describe "specific regexp" do
|
30
30
|
describe "matching the message body" do
|
@@ -33,7 +33,7 @@ describe Hipbot::Match do
|
|
33
33
|
reaction.stub(regexps: [/\Atest/])
|
34
34
|
end
|
35
35
|
|
36
|
-
its(:matches?) { should
|
36
|
+
its(:matches?) { should be_truthy }
|
37
37
|
end
|
38
38
|
|
39
39
|
describe "not matching message body" do
|
@@ -42,7 +42,7 @@ describe Hipbot::Match do
|
|
42
42
|
reaction.stub(regexps: [/\Arandom/])
|
43
43
|
end
|
44
44
|
|
45
|
-
its(:matches?) { should
|
45
|
+
its(:matches?) { should be_falsy }
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -53,7 +53,7 @@ describe Hipbot::Match do
|
|
53
53
|
reaction.stub(regexps: [/\Awat/, /\Atest/])
|
54
54
|
end
|
55
55
|
|
56
|
-
its(:matches?) { should
|
56
|
+
its(:matches?) { should be_truthy }
|
57
57
|
end
|
58
58
|
|
59
59
|
describe "not matching message body" do
|
@@ -62,7 +62,7 @@ describe Hipbot::Match do
|
|
62
62
|
reaction.stub(regexps: [/\Awat/, /\Arandom/])
|
63
63
|
end
|
64
64
|
|
65
|
-
its(:matches?) { should
|
65
|
+
its(:matches?) { should be_falsy }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -72,7 +72,7 @@ describe Hipbot::Match do
|
|
72
72
|
reaction.stub(condition: proc { true })
|
73
73
|
end
|
74
74
|
|
75
|
-
its(:matches?) { should
|
75
|
+
its(:matches?) { should be_truthy }
|
76
76
|
end
|
77
77
|
|
78
78
|
describe "returning false" do
|
@@ -80,7 +80,7 @@ describe Hipbot::Match do
|
|
80
80
|
reaction.stub(condition: proc { false })
|
81
81
|
end
|
82
82
|
|
83
|
-
its(:matches?) { should
|
83
|
+
its(:matches?) { should be_falsy }
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
data/spec/unit/message_spec.rb
CHANGED
@@ -56,13 +56,13 @@ describe Hipbot::Message do
|
|
56
56
|
it "should be for bot" do
|
57
57
|
user = double(mention: 'robot')
|
58
58
|
message = subject.new('hello @robot!', room, sender)
|
59
|
-
message.for?(user).should
|
59
|
+
message.for?(user).should be_truthy
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should not be for bot" do
|
63
63
|
user = double(mention: 'robot')
|
64
64
|
message = subject.new('hello @tom!', room, sender)
|
65
|
-
message.for?(user).should
|
65
|
+
message.for?(user).should be_falsy
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'knows its recipients' do
|
data/spec/unit/reaction_spec.rb
CHANGED
@@ -8,27 +8,27 @@ describe Hipbot::Reaction do
|
|
8
8
|
let(:reaction){ subject.new(@plugin, options, @block) }
|
9
9
|
|
10
10
|
it '#in_any_room?' do
|
11
|
-
reaction.in_any_room?.should
|
11
|
+
reaction.in_any_room?.should be_falsy
|
12
12
|
options[:room] = true
|
13
|
-
reaction.in_any_room?.should
|
13
|
+
reaction.in_any_room?.should be_truthy
|
14
14
|
end
|
15
15
|
|
16
16
|
it '#to_anything?' do
|
17
|
-
reaction.to_anything?.should
|
17
|
+
reaction.to_anything?.should be_truthy
|
18
18
|
reaction.options[:regexps] = nil
|
19
|
-
reaction.to_anything?.should
|
19
|
+
reaction.to_anything?.should be_truthy
|
20
20
|
end
|
21
21
|
|
22
22
|
it '#from_anywhere?' do
|
23
|
-
reaction.from_anywhere?.should
|
23
|
+
reaction.from_anywhere?.should be_truthy
|
24
24
|
reaction.options[:room] = nil
|
25
|
-
reaction.from_anywhere?.should
|
25
|
+
reaction.from_anywhere?.should be_truthy
|
26
26
|
end
|
27
27
|
|
28
28
|
it '#condition' do
|
29
|
-
reaction.condition.call.should
|
29
|
+
reaction.condition.call.should be_truthy
|
30
30
|
reaction.options[:if] = proc{ false }
|
31
|
-
reaction.condition.call.should
|
31
|
+
reaction.condition.call.should be_falsy
|
32
32
|
end
|
33
33
|
|
34
34
|
it '#delete' do
|
@@ -45,15 +45,15 @@ describe Hipbot::Reaction do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it '#from_all?' do
|
48
|
-
reaction.from_all?.should
|
48
|
+
reaction.from_all?.should be_truthy
|
49
49
|
reaction.options[:room] = nil
|
50
|
-
reaction.from_all?.should
|
50
|
+
reaction.from_all?.should be_truthy
|
51
51
|
end
|
52
52
|
|
53
53
|
it '#global?' do
|
54
|
-
reaction.global?.should
|
54
|
+
reaction.global?.should be_falsy
|
55
55
|
reaction.options = { global: true }
|
56
|
-
reaction.global?.should
|
56
|
+
reaction.global?.should be_truthy
|
57
57
|
end
|
58
58
|
|
59
59
|
it '#plugin_name' do
|
@@ -67,9 +67,9 @@ describe Hipbot::Reaction do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it '#to_private_message?' do
|
70
|
-
reaction.to_private_message?.should
|
70
|
+
reaction.to_private_message?.should be_falsy
|
71
71
|
reaction.options[:room] = false
|
72
|
-
reaction.to_private_message?.should
|
72
|
+
reaction.to_private_message?.should be_truthy
|
73
73
|
end
|
74
74
|
|
75
75
|
it '#regexps' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hipbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartosz Kopiński
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: xmpp4r-hipchat
|
@@ -109,6 +109,20 @@ dependencies:
|
|
109
109
|
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rspec-its
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
112
126
|
- !ruby/object:Gem::Dependency
|
113
127
|
name: guard-rspec
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,26 +157,30 @@ files:
|
|
143
157
|
- bin/hipbot
|
144
158
|
- hipbot.gemspec
|
145
159
|
- lib/hipbot.rb
|
160
|
+
- lib/hipbot/adaptable.rb
|
146
161
|
- lib/hipbot/adapter.rb
|
147
162
|
- lib/hipbot/adapters/hipchat.rb
|
148
|
-
- lib/hipbot/adapters/hipchat/
|
163
|
+
- lib/hipbot/adapters/hipchat/client.rb
|
149
164
|
- lib/hipbot/adapters/shell.rb
|
165
|
+
- lib/hipbot/adapters/slack.rb
|
166
|
+
- lib/hipbot/adapters/slack/client.rb
|
150
167
|
- lib/hipbot/adapters/telnet.rb
|
168
|
+
- lib/hipbot/adapters/xmpp.rb
|
169
|
+
- lib/hipbot/adapters/xmpp/client.rb
|
151
170
|
- lib/hipbot/bot.rb
|
152
|
-
- lib/hipbot/cache.rb
|
153
171
|
- lib/hipbot/callbacks/base.rb
|
154
|
-
- lib/hipbot/callbacks/invite.rb
|
155
172
|
- lib/hipbot/callbacks/lobby_presence.rb
|
156
173
|
- lib/hipbot/callbacks/message.rb
|
157
174
|
- lib/hipbot/callbacks/presence.rb
|
158
175
|
- lib/hipbot/callbacks/private_message.rb
|
176
|
+
- lib/hipbot/callbacks/room_invite.rb
|
159
177
|
- lib/hipbot/callbacks/room_message.rb
|
160
178
|
- lib/hipbot/callbacks/room_presence.rb
|
179
|
+
- lib/hipbot/callbacks/room_topic.rb
|
161
180
|
- lib/hipbot/configurable.rb
|
162
181
|
- lib/hipbot/configuration.rb
|
163
182
|
- lib/hipbot/helpers.rb
|
164
|
-
- lib/hipbot/http.rb
|
165
|
-
- lib/hipbot/logger.rb
|
183
|
+
- lib/hipbot/helpers/http.rb
|
166
184
|
- lib/hipbot/match.rb
|
167
185
|
- lib/hipbot/matchable.rb
|
168
186
|
- lib/hipbot/message.rb
|
@@ -178,6 +196,8 @@ files:
|
|
178
196
|
- lib/hipbot/storages/hash.rb
|
179
197
|
- lib/hipbot/storages/mongoid.rb
|
180
198
|
- lib/hipbot/user.rb
|
199
|
+
- lib/hipbot/utilities/cache.rb
|
200
|
+
- lib/hipbot/utilities/logger.rb
|
181
201
|
- lib/hipbot/version.rb
|
182
202
|
- spec/integration/my_hipbot.rb
|
183
203
|
- spec/integration/my_hipbot_spec.rb
|
@@ -211,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
231
|
version: '0'
|
212
232
|
requirements: []
|
213
233
|
rubyforge_project:
|
214
|
-
rubygems_version: 2.
|
234
|
+
rubygems_version: 2.5.1
|
215
235
|
signing_key:
|
216
236
|
specification_version: 4
|
217
237
|
summary: Hipbot is a XMPP bot for HipChat, written in Ruby with EventMachine.
|