slack-smart-bot 1.6.7 → 1.6.8

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: 5c9d526f540bb7d4c155b112cba9a04cb7b9ab54885d907434a155e5b67e329b
4
- data.tar.gz: 34df5affebadc0f812bc457a41e5cecb0c414c5cbfff04a14bbc6cbb3b8ccae0
3
+ metadata.gz: d8beec65b75d11296e5004d8d365e85e4ae7c8ebc8c8d4dffd913a723b3094c1
4
+ data.tar.gz: af507d5d01eae40db5001227f375d3c6e46b0e45ab448f81b390dad4af9d046a
5
5
  SHA512:
6
- metadata.gz: ac91e223e10df1eb7fdcadb398133cc016e09ece01ef5956d8344721abc541dd9e308bd0f12da8220d274c43dfa77c93e3a7990a40fecad40e29e8ef98093e88
7
- data.tar.gz: 15f8c7c141159602355a862159a8b231614001c4ffd61354778254424624d8111a2a3ab03913f55e433799bced95835097348642b952bbf9fc8acd94b7957e51
6
+ metadata.gz: 4b32a7967366c7ff3a3e9036a458173063c646bc0e4414fd8920fd0c34f2b70efa612a56aca9638101462fd294b909fe350d162c899eb08ae847fb25f47d217b
7
+ data.tar.gz: e8cc5c61049baf6c99832b7158807f7b0b0249df829ca41fd93ed68d9796b5da914df00223610a3828bd35542c172b9e3629f32f32ab77aee99c1acdd0ffbccc
@@ -3,8 +3,11 @@ class SlackSmartBot
3
3
  #to send a file to an user or channel
4
4
  #send_file(dest, 'the message', "#{project_folder}/temp/logs_ptBI.log", 'message to be sent', 'text/plain', "text")
5
5
  #send_file(dest, 'the message', "#{project_folder}/temp/example.jpeg", 'message to be sent', 'image/jpeg', "jpg")
6
- def send_file(to, msg, file, title, format, type = "text")
6
+ #send_file(dest, 'the message', "", 'message to be sent', 'text/plain', "ruby", content: "the content to be sent when no file supplied")
7
+ #send_file(dest, 'the message', "myfile.rb", 'message to be sent', 'text/plain', "ruby", content: "the content to be sent when no file supplied")
8
+ def send_file(to, msg, file, title, format, type = "text", content: '')
7
9
  unless config[:simulate]
10
+ file = 'myfile' if file.to_s == '' and content!=''
8
11
  if to[0] == "U" #user
9
12
  im = client.web_client.im_open(user: to)
10
13
  channel = im["channel"]["id"]
@@ -18,16 +21,29 @@ class SlackSmartBot
18
21
  ts = nil
19
22
  end
20
23
 
21
- client.web_client.files_upload(
22
- channels: channel,
23
- as_user: true,
24
- file: Faraday::UploadIO.new(file, format),
25
- title: title,
26
- filename: file,
27
- filetype: type,
28
- initial_comment: msg,
29
- thread_ts: ts
30
- )
24
+ if content.to_s == ''
25
+ client.web_client.files_upload(
26
+ channels: channel,
27
+ as_user: true,
28
+ file: Faraday::UploadIO.new(file, format),
29
+ title: title,
30
+ filename: file,
31
+ filetype: type,
32
+ initial_comment: msg,
33
+ thread_ts: ts
34
+ )
35
+ else
36
+ client.web_client.files_upload(
37
+ channels: channel,
38
+ as_user: true,
39
+ content: content,
40
+ title: title,
41
+ filename: file,
42
+ filetype: type,
43
+ initial_comment: msg,
44
+ thread_ts: ts
45
+ )
46
+ end
31
47
  end
32
48
  end
33
49
 
@@ -198,7 +198,13 @@ class SlackSmartBot
198
198
  sleep 0.2
199
199
  resp_repl = file_output_repl.read
200
200
  if resp_repl.to_s!=''
201
- respond resp_repl, dest
201
+ if resp_repl.to_s.lines.count < 60
202
+ respond resp_repl, dest
203
+ else
204
+ resp_repl.gsub!(/^```/,'')
205
+ resp_repl.gsub!(/```$/,'')
206
+ send_file(dest, "", 'response.rb', "", 'text/plain', "ruby", content: resp_repl)
207
+ end
202
208
  end
203
209
  rescue Exception => excp
204
210
  @logger.fatal excp
@@ -15,7 +15,7 @@ class SlackSmartBot
15
15
  message = ""
16
16
  @repls.sort.to_h.each do |session_name, repl|
17
17
  if (repl.creator_name == user.name or repl.type == :public) or (config.admins.include?(user.name) and typem == :on_dm)
18
- message += "(#{repl.type}) *#{session_name}*: #{repl.description} / created: #{repl.created} / accessed: #{repl.accessed} / creator: <@#{repl.creator_name}> / runs: #{repl.runs_by_creator+repl.runs_by_others} / gets: #{repl.gets} \n"
18
+ message += "(#{repl.type}) *#{session_name}*: #{repl.description} / created: #{repl.created} / accessed: #{repl.accessed} / creator: #{repl.creator_name} / runs: #{repl.runs_by_creator+repl.runs_by_others} / gets: #{repl.gets} \n"
19
19
  end
20
20
  end
21
21
  message = "No repls created" if message == ''
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-smart-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.7
4
+ version: 1.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-20 00:00:00.000000000 Z
11
+ date: 2020-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slack-ruby-client