lita-tipbot 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 +17 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/lib/lita/handlers/tipbot.rb +266 -0
- data/lib/lita-tipbot.rb +12 -0
- data/lita-tipbot.gemspec +25 -0
- data/locales/en.yml +4 -0
- data/spec/lita/handlers/tipbot_spec.rb +120 -0
- data/spec/spec_helper.rb +6 -0
- data/templates/.gitkeep +0 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9f5a96e1f9175162545271fb31e38e31364fc77a
|
4
|
+
data.tar.gz: 14febc648cb86f7258ada9b18afd3e3ed66c11e1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 19a018c8a40300267be9b0384d63b78808edc8cd8f2db29db75b06719dd3d627bb8d5df4e047154930cc463ba910b532d098680a239e33b3c2f41af1cb808cc8
|
7
|
+
data.tar.gz: 3d3c649ed7d09dedcd159b26fb9f161a2f832d0ca0b48c88a8e3f5fbed72d51014f9be38d57205bf414f8a0cbac52898bc276a52df7a8efbcd1e29bcaa93f563
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
lita-tipbot
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.2.1
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) [2015] [Chris Chalfant]
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# lita-tipbot
|
2
|
+
|
3
|
+
Tip people with dogecoins! Based on https://gist.github.com/ninetwentyfour/9063547
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add lita-tipbot to your Lita instance's Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem "lita-tipbot"
|
11
|
+
```
|
12
|
+
|
13
|
+
You or someone you know needs to setup and run https://github.com/ninetwentyfour/tipbot
|
14
|
+
|
15
|
+
## Configuration
|
16
|
+
|
17
|
+
TIPBOT_AUTH_TOKEN
|
18
|
+
TIPBOT_URL
|
19
|
+
HIPCHAT_API_TOKEN
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Describe the plugin's features and how to use them.
|
24
|
+
|
25
|
+
## TO THE MOON!
|
26
|
+
|
27
|
+
░░░░░░░░░▄░░░░░░░░░░░░░░▄░░░░
|
28
|
+
░░░░░░░░▌▒█░░░░░░░░░░░▄▀▒▌░░░
|
29
|
+
░░░░░░░░▌▒▒█░░░░░░░░▄▀▒▒▒▐░░░
|
30
|
+
░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐░░░
|
31
|
+
░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐░░░
|
32
|
+
░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌░░░
|
33
|
+
░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌░░
|
34
|
+
░░▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐░░
|
35
|
+
░▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌░
|
36
|
+
░▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌░
|
37
|
+
▀▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒▐░
|
38
|
+
▐▒▒▐▀▐▀▒░▄▄▒▄▒▒▒▒▒▒░▒░▒░▒▒▒▒▌
|
39
|
+
▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐░
|
40
|
+
░▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒░▒░▒░▒░▒▒▒▌░
|
41
|
+
░▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▄▒▒▐░░
|
42
|
+
░░▀▄▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▄▒▒▒▒▌░░
|
43
|
+
░░░░▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀░░░
|
44
|
+
░░░░░░▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀░░░░░
|
45
|
+
░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▀▀░░░░░░░░
|
data/Rakefile
ADDED
@@ -0,0 +1,266 @@
|
|
1
|
+
require 'hipchat-api'
|
2
|
+
require 'digest'
|
3
|
+
require 'httparty'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Lita
|
7
|
+
module Handlers
|
8
|
+
class TipbotApi
|
9
|
+
attr_accessor :base_url, :auth_token, :log
|
10
|
+
|
11
|
+
def initialize(params)
|
12
|
+
@base_url = params[:url]
|
13
|
+
@auth_token = params[:auth_token]
|
14
|
+
@log = params[:log]
|
15
|
+
end
|
16
|
+
|
17
|
+
def rest_get(url)
|
18
|
+
headers = {
|
19
|
+
'Authorization' => auth_token,
|
20
|
+
'Accept' => 'application/json'
|
21
|
+
}
|
22
|
+
HTTParty.get(url, headers: headers)
|
23
|
+
end
|
24
|
+
|
25
|
+
def rest_post(url, payload)
|
26
|
+
headers = {
|
27
|
+
'Authorization' => auth_token,
|
28
|
+
'Accept' => 'application/json',
|
29
|
+
'Content-Type' => 'application/json'
|
30
|
+
}
|
31
|
+
HTTParty.post(url, headers: headers, body: payload)
|
32
|
+
end
|
33
|
+
|
34
|
+
def register(hash)
|
35
|
+
url = "#{base_url}/wallet/#{hash}/register"
|
36
|
+
resp = rest_get url
|
37
|
+
resp.body
|
38
|
+
end
|
39
|
+
|
40
|
+
def address(hash)
|
41
|
+
url = "#{base_url}/wallet/#{hash}"
|
42
|
+
resp = rest_get url
|
43
|
+
data = JSON.parse resp.body
|
44
|
+
data['address']
|
45
|
+
end
|
46
|
+
|
47
|
+
def balance(hash)
|
48
|
+
url = "#{base_url}/wallet/#{hash}/balance"
|
49
|
+
resp = rest_get url
|
50
|
+
data = JSON.parse resp.body
|
51
|
+
data['balance'] # TODO: check for NaN
|
52
|
+
end
|
53
|
+
|
54
|
+
def history(hash)
|
55
|
+
url = "#{base_url}/wallet/#{hash}/history"
|
56
|
+
resp = rest_get url
|
57
|
+
resp.body
|
58
|
+
end
|
59
|
+
|
60
|
+
def tip(giver_hash, receiver_hash, amount)
|
61
|
+
url = "#{base_url}/wallet/tip"
|
62
|
+
|
63
|
+
payload = {
|
64
|
+
from: giver_hash,
|
65
|
+
to: reciever_hash,
|
66
|
+
amount: amount
|
67
|
+
}.to_json
|
68
|
+
|
69
|
+
resp = rest_post url, payload
|
70
|
+
resp.body
|
71
|
+
end
|
72
|
+
|
73
|
+
def withdraw(src_hash, dest_address)
|
74
|
+
url = "#{base_url}/wallet/#{src_hash}/withdraw/#{dest_address}"
|
75
|
+
resp = rest_get url
|
76
|
+
data = JSON.parse(resp.body)
|
77
|
+
data['message']
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class Tipbot < Handler
|
82
|
+
# TODO: store user's hash in redis for later lookup?
|
83
|
+
|
84
|
+
config :hipchat_api_token
|
85
|
+
config :tipbot_auth_token
|
86
|
+
config :tipbot_url
|
87
|
+
config :emails_to_exclude
|
88
|
+
|
89
|
+
route(/^tipbot register/i, :register, help: {
|
90
|
+
"tipbot register" => "register to use tipbot (only needed if you have never been tipped)"
|
91
|
+
})
|
92
|
+
|
93
|
+
route(/^tipbot address/i, :address, help: {
|
94
|
+
"tipbot address" => "show the address you can send coins to for tipping"
|
95
|
+
})
|
96
|
+
|
97
|
+
route(/^tipbot balance/i, :balance, help: {
|
98
|
+
"tipbot balance" => "show your current balance"
|
99
|
+
})
|
100
|
+
|
101
|
+
route(/^tipbot history/i, :history, help: {
|
102
|
+
"tipbot history" => "show transaction history"
|
103
|
+
})
|
104
|
+
|
105
|
+
route(/^tipbot tip (.\S*) (.\d*)/i, :tip, help: {
|
106
|
+
"tipbot tip @mentionName amount" => "tip someone coins e.g. tipbot tip @ExampleUser 10"
|
107
|
+
})
|
108
|
+
|
109
|
+
route(/^tipbot withdraw (.*)/i, :withdraw, help: {
|
110
|
+
"tipbot withdraw personalAddress" => "withdraw your tips into your personal wallet"
|
111
|
+
})
|
112
|
+
|
113
|
+
route(/^tipbot make it rain/i, :make_it_rain, help: {
|
114
|
+
"tipbot make it rain" => "tip every active participant in the room"
|
115
|
+
})
|
116
|
+
|
117
|
+
route(/^tipbot make it wayne/i, :make_it_wayne)
|
118
|
+
route(/^tipbot make it blaine/i, :make_it_blaine)
|
119
|
+
route(/^tipbot make it crane/i, :make_it_crane)
|
120
|
+
route(/^tipbot make it reign/i, :make_it_reign)
|
121
|
+
|
122
|
+
def register(response)
|
123
|
+
hash = user_hash(response.user.mention_name)
|
124
|
+
|
125
|
+
log.info "Registering #{hash}"
|
126
|
+
body = tipbot_api.register hash
|
127
|
+
|
128
|
+
log.debug "register response: #{body}"
|
129
|
+
# TODO: check for errors
|
130
|
+
response.reply "You have been registered."
|
131
|
+
end
|
132
|
+
|
133
|
+
def address(response)
|
134
|
+
hash = user_hash(response.user.mention_name)
|
135
|
+
response.reply tipbot_api.address(hash)
|
136
|
+
end
|
137
|
+
|
138
|
+
def balance(response)
|
139
|
+
hash = user_hash(response.user.mention_name)
|
140
|
+
response.reply tipbot_api.balance(hash).to_s
|
141
|
+
end
|
142
|
+
|
143
|
+
def history(response)
|
144
|
+
hash = user_hash(response.user.mention_name)
|
145
|
+
response.reply tipbot_api.history(hash)
|
146
|
+
end
|
147
|
+
|
148
|
+
def tip(response)
|
149
|
+
recipient, amount = response.match_data[1..2]
|
150
|
+
from_hash = user_hash(response.user.mention_name)
|
151
|
+
to_hash = user_hash(recipient.slice(1..-1))
|
152
|
+
tipbot_api.tip(from_hash, to_hash, amount)
|
153
|
+
response.reply "Tip sent! Such kind shibe."
|
154
|
+
end
|
155
|
+
|
156
|
+
def withdraw(response)
|
157
|
+
src_hash = user_hash(response.user.mention_name)
|
158
|
+
dest_address = response.match_data[1]
|
159
|
+
|
160
|
+
resp = tipbot_api.withdraw(src_hash, dest_address)
|
161
|
+
response.reply resp
|
162
|
+
end
|
163
|
+
|
164
|
+
def make_it_rain(response)
|
165
|
+
images = [
|
166
|
+
"http://disinfo.s3.amazonaws.com/wp-content/uploads/2013/12/make-it-rain-1jk6.jpg",
|
167
|
+
"http://voice.instructure.com/Portals/166399/images/scrooge-mcduck-make-it-rain.jpeg",
|
168
|
+
"http://cdn01.dailycaller.com/wp-content/uploads/2012/10/Big-Bird-Makin-It-Rain-e1349457102996.jpeg",
|
169
|
+
"http://i.imgur.com/jSaI0pv.jpg",
|
170
|
+
"http://i.imgur.com/0Rz84wK.gif"
|
171
|
+
]
|
172
|
+
|
173
|
+
response.reply([
|
174
|
+
"#{response.user.name} is makin' it rain!",
|
175
|
+
images.sample
|
176
|
+
])
|
177
|
+
|
178
|
+
src_hash = user_hash(response.user.mention_name)
|
179
|
+
room_jid = response.message.source.room
|
180
|
+
users = active_room_members room_jid
|
181
|
+
|
182
|
+
users.shuffle.each do |user|
|
183
|
+
log.info "tipping #{user['email']}"
|
184
|
+
|
185
|
+
dest_hash = hash_email user['email']
|
186
|
+
log.debug "SRC HASH: #{src_hash}"
|
187
|
+
log.debug "DEST HASH: #{dest_hash}"
|
188
|
+
log.debug "NAME: #{user['name']}"
|
189
|
+
|
190
|
+
response.reply "A coin for #{user['name']}!"
|
191
|
+
tipbot_api.tip src_hash, dest_hash, 1
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
attr_writer :hipchat_api, :tipbot_api
|
196
|
+
|
197
|
+
def hipchat_api
|
198
|
+
if @hipchat_api.nil?
|
199
|
+
@hipchat_api = HipChat::API.new(config.hipchat_api_token)
|
200
|
+
end
|
201
|
+
@hipchat_api
|
202
|
+
end
|
203
|
+
|
204
|
+
def tipbot_api
|
205
|
+
if @tipbot_api.nil?
|
206
|
+
params = {
|
207
|
+
url: config.tipbot_url,
|
208
|
+
auth_token: config.tipbot_auth_token,
|
209
|
+
log: log
|
210
|
+
}
|
211
|
+
@tipbot_api = TipbotApi.new(params)
|
212
|
+
end
|
213
|
+
@tipbot_api
|
214
|
+
end
|
215
|
+
|
216
|
+
def user_hash(mention_name)
|
217
|
+
user_data = hipchat_api.users_list
|
218
|
+
user = user_data['users'].select {|u| u['mention_name'] == mention_name}.first
|
219
|
+
hash_email user['email']
|
220
|
+
end
|
221
|
+
|
222
|
+
def hash_email(email)
|
223
|
+
Digest::MD5.hexdigest email
|
224
|
+
end
|
225
|
+
|
226
|
+
# TODO: many of these methods could be useful to other handlers
|
227
|
+
|
228
|
+
# return a list of hipchat api v1 user hashes
|
229
|
+
# exclude any user with email in config.emails_to_exclude
|
230
|
+
# exclude any non-active user
|
231
|
+
# TODO: dont make an api call for every participant
|
232
|
+
# instead: make one call for all users, then check
|
233
|
+
# to see if each is an active participant
|
234
|
+
def active_room_members(room_jid)
|
235
|
+
data = room_data(room_jid)
|
236
|
+
results = []
|
237
|
+
data['participants'].each do |p|
|
238
|
+
user = hipchat_api.users_show(p['id'])
|
239
|
+
next if user['user']['status'] != 'available'
|
240
|
+
next if exclude_user? user['user']
|
241
|
+
results << user['user']
|
242
|
+
end
|
243
|
+
results
|
244
|
+
end
|
245
|
+
|
246
|
+
def exclude_user?(user_hash)
|
247
|
+
config.emails_to_exclude.include?(user_hash['email'])
|
248
|
+
end
|
249
|
+
|
250
|
+
def room_data(room_jid)
|
251
|
+
room_id = room_id_from_jid room_jid
|
252
|
+
data = hipchat_api.rooms_show room_id
|
253
|
+
data['room']
|
254
|
+
end
|
255
|
+
|
256
|
+
def room_id_from_jid(room_jid)
|
257
|
+
data = hipchat_api.rooms_list
|
258
|
+
room = data['rooms'].select {|r| r['xmpp_jid'] == room_jid}.first
|
259
|
+
room.nil? ? nil : room['id']
|
260
|
+
end
|
261
|
+
|
262
|
+
end
|
263
|
+
|
264
|
+
Lita.register_handler(Tipbot)
|
265
|
+
end
|
266
|
+
end
|
data/lib/lita-tipbot.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "lita"
|
2
|
+
|
3
|
+
Lita.load_locales Dir[File.expand_path(
|
4
|
+
File.join("..", "..", "locales", "*.yml"), __FILE__
|
5
|
+
)]
|
6
|
+
|
7
|
+
require "lita/handlers/tipbot"
|
8
|
+
|
9
|
+
Lita::Handlers::Tipbot.template_root File.expand_path(
|
10
|
+
File.join("..", "..", "templates"),
|
11
|
+
__FILE__
|
12
|
+
)
|
data/lita-tipbot.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-tipbot"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Chris Chalfant"]
|
5
|
+
spec.email = ["chalfants@gmail.com"]
|
6
|
+
spec.description = "Tip people with dogecoins!"
|
7
|
+
spec.summary = "Tip people with dogecoins!"
|
8
|
+
spec.homepage = "https://github.com/chalfant/lita-tipbot"
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_runtime_dependency "lita", ">= 4.3"
|
18
|
+
spec.add_runtime_dependency "hipchat-api"
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
spec.add_development_dependency "pry-byebug"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rack-test"
|
24
|
+
spec.add_development_dependency "rspec", ">= 3.0.0"
|
25
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
describe Lita::Handlers::Tipbot, lita_handler: true do
|
5
|
+
let(:users_list) {
|
6
|
+
{
|
7
|
+
'users' => [
|
8
|
+
{'mention_name' => user.mention_name, 'email' => 'foo@bar.com' },
|
9
|
+
{'mention_name' => 'foo', 'email' => 'bar@foo.com' }
|
10
|
+
]
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
before(:each) { subject.hipchat_api = double(users_list: users_list) }
|
15
|
+
|
16
|
+
it { is_expected.to route("tipbot register").to(:register) }
|
17
|
+
it { is_expected.to route("tipbot address").to(:address) }
|
18
|
+
it { is_expected.to route("tipbot balance").to(:balance) }
|
19
|
+
it { is_expected.to route("tipbot history").to(:history) }
|
20
|
+
it { is_expected.to route("tipbot tip @foo 10").to(:tip) }
|
21
|
+
it { is_expected.to route("tipbot withdraw address").to(:withdraw) }
|
22
|
+
it { is_expected.to route("tipbot make it rain").to(:make_it_rain) }
|
23
|
+
it { is_expected.to route("tipbot make it wayne").to(:make_it_wayne) }
|
24
|
+
it { is_expected.to route("tipbot make it blaine").to(:make_it_blaine) }
|
25
|
+
it { is_expected.to route("tipbot make it crane").to(:make_it_crane) }
|
26
|
+
it { is_expected.to route("tipbot make it reign").to(:make_it_reign) }
|
27
|
+
|
28
|
+
it 'registers the user' do
|
29
|
+
subject.tipbot_api = double(register: 'foo')
|
30
|
+
send_message("tipbot register")
|
31
|
+
expect(replies.first).to eq("You have been registered.")
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'responds with the address' do
|
35
|
+
subject.tipbot_api = double(address: 'foo')
|
36
|
+
send_message("tipbot address")
|
37
|
+
expect(replies.first).to eq('foo')
|
38
|
+
end
|
39
|
+
|
40
|
+
it "responds with the user's balance as a string" do
|
41
|
+
subject.tipbot_api = double(balance: 1337)
|
42
|
+
send_message("tipbot balance")
|
43
|
+
expect(replies.first).to eq(1337.to_s)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "responds with the user's history" do
|
47
|
+
history = {'foo': 0}.to_json
|
48
|
+
subject.tipbot_api = double(history: history)
|
49
|
+
send_message("tipbot history")
|
50
|
+
expect(replies.first).to eq(history)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'submits a tip' do
|
54
|
+
subject.tipbot_api = double(tip: '')
|
55
|
+
send_message("tipbot tip @foo 25")
|
56
|
+
expect(replies.first).to eq("Tip sent! Such kind shibe.")
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'responds with withdraw address' do
|
60
|
+
subject.tipbot_api = double(withdraw: 'foo')
|
61
|
+
send_message("tipbot withdraw address")
|
62
|
+
expect(replies.first).to eq('foo')
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#hash_email' do
|
66
|
+
it 'hashes properly' do
|
67
|
+
email = 'cchalfant@leafsoftwaresolutions.com'
|
68
|
+
hash = '554976db892eff514c1bc35fbd736983'
|
69
|
+
expect(subject.hash_email(email)).to eq(hash)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#active_room_members' do
|
74
|
+
let(:room_data) {
|
75
|
+
{
|
76
|
+
'participants' => [
|
77
|
+
{'id' => 1}
|
78
|
+
]
|
79
|
+
}
|
80
|
+
}
|
81
|
+
before(:each) do
|
82
|
+
allow(subject).to receive(:room_data).and_return(room_data)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'excludes users with status != available' do
|
86
|
+
user = {
|
87
|
+
'user' => {
|
88
|
+
'email' => 'foo@bar.com',
|
89
|
+
'status' => 'not_available'
|
90
|
+
}
|
91
|
+
}
|
92
|
+
subject.hipchat_api = double(users_show: user)
|
93
|
+
expect(subject.active_room_members('foo')).to be_empty
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'excludes users in the email exclusion list' do
|
97
|
+
user = {
|
98
|
+
'user' => {
|
99
|
+
'email' => 'foo@bar.com',
|
100
|
+
'status' => 'available'
|
101
|
+
}
|
102
|
+
}
|
103
|
+
subject.hipchat_api = double(users_show: user)
|
104
|
+
allow(subject).to receive(:exclude_user?).and_return(true)
|
105
|
+
expect(subject.active_room_members('foo')).to be_empty
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'allows available non-excluded users' do
|
109
|
+
user = {
|
110
|
+
'user' => {
|
111
|
+
'email' => 'foo@bar.com',
|
112
|
+
'status' => 'available'
|
113
|
+
}
|
114
|
+
}
|
115
|
+
subject.hipchat_api = double(users_show: user)
|
116
|
+
allow(subject).to receive(:exclude_user?).and_return(false)
|
117
|
+
expect(subject.active_room_members('foo').size).to eq(1)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/templates/.gitkeep
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-tipbot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Chalfant
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hipchat-api
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
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.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
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
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rack-test
|
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: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 3.0.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 3.0.0
|
111
|
+
description: Tip people with dogecoins!
|
112
|
+
email:
|
113
|
+
- chalfants@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".ruby-gemset"
|
120
|
+
- ".ruby-version"
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- lib/lita-tipbot.rb
|
126
|
+
- lib/lita/handlers/tipbot.rb
|
127
|
+
- lita-tipbot.gemspec
|
128
|
+
- locales/en.yml
|
129
|
+
- spec/lita/handlers/tipbot_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
- templates/.gitkeep
|
132
|
+
homepage: https://github.com/chalfant/lita-tipbot
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata:
|
136
|
+
lita_plugin_type: handler
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.4.6
|
154
|
+
signing_key:
|
155
|
+
specification_version: 4
|
156
|
+
summary: Tip people with dogecoins!
|
157
|
+
test_files:
|
158
|
+
- spec/lita/handlers/tipbot_spec.rb
|
159
|
+
- spec/spec_helper.rb
|