slack-smart-bot 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/slack-smart-bot_rules.rb +53 -45
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7356f402c253b661ed525a109e733655d7a515645235a8027030ef453a38e9c4
4
- data.tar.gz: 40fd18df8ee38698d920bf74ae66abfc74badd4d3f7bc169809d5025088d83cf
3
+ metadata.gz: 1f04209396105787c535cc023a3af0b3e63bb57f5ed62ef379f5d63c3f8b08ef
4
+ data.tar.gz: d5fb33126522405993050549bca48fae7ce731941629a5b43d770078d8d630df
5
5
  SHA512:
6
- metadata.gz: d7abd1759506ffe9f8914696d27acad6f8ca61437f1fdc7def03e5be6a4919092dcfc1ff624740f56985f074c409879894f0ef19a9c3873614c4c2fb3e921267
7
- data.tar.gz: 719560ab0d51721cef0334c9201a38694539487a582648396a1aada2382bae70cf720b9cbecb145a07fbd74303505bfbf00c267e76342ff58b3bf91239f1ef84
6
+ metadata.gz: 31b67a7e6215163517f9eca2e2131763d14709d3fef207fdb305e392ad28d0f7cc5db7d044aa8dd3e6a161a4e553053d74fbf74b71c1e0e625c6635c123adcd1
7
+ data.tar.gz: 1d0fdcf1e83bc064e9ae8e0440798c5a066ca87c1383a96fda55e11cfa378bc4fdd8ef3eaddffedd9720a9bbf6fb675eddbc3d14448458aeb94e90420bcd6ec6
@@ -10,7 +10,6 @@ def git_project()
10
10
  ""
11
11
  end
12
12
 
13
-
14
13
  #for the case of testing, just run this file adding in the end a call to rules with the parameters you want
15
14
  if defined?(respond)
16
15
  @testing = false
@@ -54,61 +53,70 @@ def rules(user, command, processed, dest)
54
53
  end
55
54
  end
56
55
  firstname = from.split(" ").first
57
- case command
58
-
59
- # help: ----------------------------------------------
60
- # help: `echo SOMETHING`
61
- # help: repeats SOMETHING
62
- # help:
63
- when /^echo\s(.+)/i
64
- respond $1, dest
56
+ begin
57
+ case command
65
58
 
66
59
  # help: ----------------------------------------------
67
- # help: `go to sleep`
68
- # help: it will sleep the bot for 5 seconds
60
+ # help: `echo SOMETHING`
61
+ # help: repeats SOMETHING
69
62
  # help:
70
- when /^go\sto\ssleep/i
71
- unless @questions.keys.include?(from)
72
- ask("do you want me to take a siesta?", command, from, dest)
73
- else
74
- case @questions[from]
75
- when /yes/i, /yep/i, /sure/i
76
- @questions.delete(from)
77
- respond "I'll be sleeping for 5 secs... just for you", dest
78
- respond "zZzzzzzZZZZZZzzzzzzz!", dest
79
- sleep 5
80
- when /no/i, /nope/i, /cancel/i
81
- @questions.delete(from)
82
- respond "Thanks, I'm happy to be awake", dest
63
+ when /^echo\s(.+)/i
64
+ respond $1, dest
65
+
66
+ # help: ----------------------------------------------
67
+ # help: `go to sleep`
68
+ # help: it will sleep the bot for 5 seconds
69
+ # help:
70
+ when /^go\sto\ssleep/i
71
+ unless @questions.keys.include?(from)
72
+ ask("do you want me to take a siesta?", command, from, dest)
83
73
  else
84
- respond "I don't understand", dest
85
- ask("are you sure do you want me to sleep? (yes or no)", "go to sleep", from, dest)
74
+ case @questions[from]
75
+ when /yes/i, /yep/i, /sure/i
76
+ @questions.delete(from)
77
+ respond "I'll be sleeping for 5 secs... just for you", dest
78
+ respond "zZzzzzzZZZZZZzzzzzzz!", dest
79
+ sleep 5
80
+ when /no/i, /nope/i, /cancel/i
81
+ @questions.delete(from)
82
+ respond "Thanks, I'm happy to be awake", dest
83
+ else
84
+ respond "I don't understand", dest
85
+ ask("are you sure do you want me to sleep? (yes or no)", "go to sleep", from, dest)
86
+ end
86
87
  end
87
- end
88
88
 
89
- # help: ----------------------------------------------
90
- # help: `run something`
91
- # help: It will run the process and report the results when done
92
- # help:
93
- when /^run something/i
94
- respond "Running", dest
89
+ # help: ----------------------------------------------
90
+ # help: `run something`
91
+ # help: It will run the process and report the results when done
92
+ # help:
93
+ when /^run something/i
94
+ respond "Running", dest
95
95
 
96
- process_to_run = "ruby -v"
97
- process_to_run = ("cd #{project_folder} &&" + process_to_run) if defined?(project_folder)
98
- stdout, stderr, status = Open3.capture3(process_to_run)
99
- if stderr == ""
100
- if stdout == ""
101
- respond "#{user.name}: Nothing returned.", dest
96
+ process_to_run = "ruby -v"
97
+ process_to_run = ("cd #{project_folder} &&" + process_to_run) if defined?(project_folder)
98
+ stdout, stderr, status = Open3.capture3(process_to_run)
99
+ if stderr == ""
100
+ if stdout == ""
101
+ respond "#{user.name}: Nothing returned.", dest
102
+ else
103
+ respond "#{user.name}: #{stdout}", dest
104
+ end
102
105
  else
103
- respond "#{user.name}: #{stdout}", dest
106
+ respond "#{user.name}: #{stderr}", dest
104
107
  end
105
108
  else
106
- respond "#{user.name}: #{stderr}", dest
109
+ unless processed
110
+ resp = %w{ what huh sorry }.sample
111
+ respond "#{firstname}: #{resp}?", dest
112
+ end
107
113
  end
108
- else
109
- unless processed
110
- resp = %w{ what huh sorry }.sample
111
- respond "#{firstname}: #{resp}?", dest
114
+ rescue => exception
115
+ if defined?(@logger)
116
+ @logger.fatal exception
117
+ respond "Unexpected error!! Please contact an admin to solve it: <@#{ADMIN_USERS.join('>, <@')}>", dest
118
+ else
119
+ puts exception
112
120
  end
113
121
  end
114
122
  end
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: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-16 00:00:00.000000000 Z
11
+ date: 2019-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slack-ruby-client