mos-eisley-lambda 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f47807ff37bc9efd5d01b8745fc9cfb36796876b03dc50cf5b1f5504d75cfb5
4
- data.tar.gz: a9fef8a47a8f9a7c2a7ca36122f047ecfef781f019e40bbcbf5f7eb6d423861d
3
+ metadata.gz: 93e80b178ebf50a338825f24796cd4a940360ade9c5cb4e86febddc8c698892e
4
+ data.tar.gz: fd8899967cb3969f38f2b51e2c6e4482185a7b9b690b8201aa28279e008ae0b7
5
5
  SHA512:
6
- metadata.gz: 19c4a11da675e07f0cd1fd405dbdd1013be87086ad3f93afad9c85f64de9bbc6620beb4a6ff441892ca1590b0e9e3977bfbb2cc343e82b3868ec9bd7a804ec42
7
- data.tar.gz: 4c0421f4ad6e9655845c11fac9e981e2cb7f44856744a839df504f314947afdc888e475e801aa30572815495fba9da879fb4dc867ece6e52ab1b9fc002dcb462
6
+ metadata.gz: 31260b991c3adfd3b83a88b67f10c045a5ae6caab05a49bceff69e946230a953af0a55c8107e4ab7026bb8d4b10f7fd66c183164577c09369377fb78886ad1d7
7
+ data.tar.gz: 2b8a6b426911626cdc93827638f8057aebac906925307eaf1d3488dab00c73ec61c664e6f270bd2b34ee80e4ee6982b27dce22cd91f5e0278ed0c76e601bdf30
data/lib/slack.rb CHANGED
@@ -120,33 +120,45 @@ module MosEisley
120
120
  def self.views_push(trigger_id:, view:)
121
121
  end
122
122
 
123
+ def self.conversations_members(channel:, cursor: nil, limit: nil)
124
+ params = {channel: channel}
125
+ params[:cursor] = cursor if cursor
126
+ params[:limit] = limit if limit
127
+ get_from_slack('conversations.members', params)
128
+ end
129
+
123
130
  def self.users_info(user)
124
- users_send('info', {user: user})
131
+ get_from_slack('users.info', {user: user})
125
132
  end
126
133
 
127
134
  def self.users_list(cursor: nil, limit: nil)
128
135
  params = {include_locale: true}
129
136
  params[:cursor] = cursor if cursor
130
137
  params[:limit] = limit if limit
131
- users_send('list', params)
138
+ get_from_slack('users.list', params)
132
139
  end
133
140
 
134
141
  def self.users_lookupbyemail(email)
135
- users_send('lookupByEmail', {email: email})
142
+ get_from_slack('users.lookupByEmail', {email: email})
136
143
  end
137
144
 
138
145
  def self.users_profile_get(user)
139
- users_send('profile.get', {user: user})
146
+ get_from_slack('users.profile.get', {user: user})
147
+ end
148
+
149
+ def self.auth_test
150
+ post_to_slack('auth.test', '')
140
151
  end
141
152
 
142
- def self.users_send(m, params)
153
+ private
154
+
155
+ def self.get_from_slack(m, params)
143
156
  l = MosEisley.logger
144
- call = "users.#{m}"
145
- url ||= BASE_URL + call
157
+ url ||= BASE_URL + m
146
158
  head = {authorization: "Bearer #{ENV['SLACK_BOT_ACCESS_TOKEN']}"}
147
159
  r = Neko::HTTP.get(url, params, head)
148
160
  if r[:code] != 200
149
- l.warn("#{call} HTTP failed: #{r[:message]}")
161
+ l.warn("#{m} HTTP failed: #{r[:message]}")
150
162
  return nil
151
163
  end
152
164
  begin
@@ -154,7 +166,7 @@ module MosEisley
154
166
  if h[:ok]
155
167
  return h
156
168
  else
157
- l.warn("#{call} Slack failed: #{h[:error]}")
169
+ l.warn("#{m} Slack failed: #{h[:error]}")
158
170
  l.debug("#{h[:response_metadata]}")
159
171
  return nil
160
172
  end
@@ -163,12 +175,6 @@ module MosEisley
163
175
  end
164
176
  end
165
177
 
166
- def self.auth_test
167
- post_to_slack('auth.test', '')
168
- end
169
-
170
- private
171
-
172
178
  def self.post_to_slack(method, data, url = nil)
173
179
  l = MosEisley.logger
174
180
  url ||= BASE_URL + method
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'mos-eisley-lambda'
3
- s.version = '0.5.0'
3
+ s.version = '0.5.1'
4
4
  s.authors = ['Ken J.']
5
5
  s.email = ['kenjij@gmail.com']
6
6
  s.summary = %q{Ruby based Slack bot framework, for AWS Lambda use}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mos-eisley-lambda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken J.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-14 00:00:00.000000000 Z
11
+ date: 2021-08-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby based Slack bot framework, for AWS Lambda use. Also provides helpers
14
14
  to analyze/build messages. Event based utilizing SQS.