slack-smart-bot 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -2
  3. data/lib/slack-smart-bot.rb +28 -13
  4. metadata +4 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f35296a4d203ca6571478d139003f5f17741d07a815718f8e024cc9e077a482a
4
- data.tar.gz: 9817c32b14938cf57464fe34d151836f3889843e2216c23b5f192da3a24bee5c
3
+ metadata.gz: b2722475c7547a7166a4f47ad899b89b23f40c123fc7051124c20d3475048ca9
4
+ data.tar.gz: c98ac45760450b63c7a48185abd7e3e81580991cef6bd886535c02f702bd1126
5
5
  SHA512:
6
- metadata.gz: 3ec6d3a625b4df6d6c10d96f49aba96c7b07a1b2bc03425b32c0187a35bb89b2c493b394663eb6e50430c19d6eb5fa8225f63d4960c478e0374471a11fc06873
7
- data.tar.gz: f9f76944a778989144e524dd5f40e53a37109ffa8f6ec1e613d70f9a68aa79ca324b9698d806e6ef8bf4003b0f2fb8eeafdaaab2027f0b68436c14fc5c784fed
6
+ metadata.gz: d3ee210218954d6cb8d707ae8b021c502d9d8f8d6517e86754548f55aaeeffc7e944b3d403a052c4d4e33829c7b11ad2e319e8369418b2a573c6d8382859dd71
7
+ data.tar.gz: 6619276587528d9903ae50be641c8390860c47d3a172e10efbc9d4d09b08b1db01e591e2309b3c7efff99610fbcc2bbafc3ce3598e59d3e3b08e14c2695f55e6
data/README.md CHANGED
@@ -40,11 +40,25 @@ end
40
40
 
41
41
  The MASTER_CHANNEL will be the channel where you will be able to create other bots and will have special treatment.
42
42
 
43
- The MASTER_USERS will have full access to everything. The names should be written exactly the same like they appear on Slack.
43
+ The MASTER_USERS will have full access to everything. You need to use the slack user name defined on https://YOUR_WORK_SPACE.slack.com/account/settings#username.
44
44
 
45
45
  For the token remember you need to generate a token on the Slack web for the bot user.
46
46
 
47
- This is something done in Slack, under [integrations](https://my.slack.com/services). Create a [new bot](https://my.slack.com/services/new/bot), and note its API token.
47
+ You can get one by any of these options:
48
+
49
+ - *[Slack App. Bot Token](https://api.slack.com/slack-apps)*. (Recommended)
50
+
51
+ 1) [Create a Slack App](https://api.slack.com/apps?new_app=1)
52
+
53
+ 1) Add a bot user to your app. On Add features and functionality section for your app, select *Bots*. Click on *Add a Bot User*
54
+
55
+ 1) On your app click on the menu on the left: *OAuth & Permissions* and click on *Install App to Workspace*.
56
+
57
+ 1) Copy your *Bot User OAuth Access Token*.
58
+
59
+
60
+ - *[Legacy API Token](https://api.slack.com/custom-integrations/legacy-tokens)*.
61
+
48
62
 
49
63
  *Remember to invite the smart bot to the channels where they will be accessible before creating the bot*
50
64
 
@@ -142,16 +142,18 @@ class SlackSmartBot
142
142
  end
143
143
 
144
144
  def get_bots_created
145
- if !defined?(@datetime_bots_created) or @datetime_bots_created!=File.mtime($0.gsub(".rb", "_bots.rb"))
146
- file_conf = IO.readlines($0.gsub(".rb", "_bots.rb")).join
147
- if file_conf.to_s() == ""
148
- @bots_created = {}
149
- else
150
- @bots_created = eval(file_conf)
151
- end
152
- @datetime_bots_created = File.mtime($0.gsub(".rb", "_bots.rb"))
153
- @bots_created.each do |k,v| # to be compatible with old versions
154
- v[:extended] = [] unless v.key?(:extended)
145
+ if File.exist?($0.gsub(".rb", "_bots.rb"))
146
+ if !defined?(@datetime_bots_created) or @datetime_bots_created!=File.mtime($0.gsub(".rb", "_bots.rb"))
147
+ file_conf = IO.readlines($0.gsub(".rb", "_bots.rb")).join
148
+ if file_conf.to_s() == ""
149
+ @bots_created = {}
150
+ else
151
+ @bots_created = eval(file_conf)
152
+ end
153
+ @datetime_bots_created = File.mtime($0.gsub(".rb", "_bots.rb"))
154
+ @bots_created.each do |k,v| # to be compatible with old versions
155
+ v[:extended] = [] unless v.key?(:extended)
156
+ end
155
157
  end
156
158
  end
157
159
  end
@@ -758,9 +760,22 @@ class SlackSmartBot
758
760
  if @status == :on
759
761
  respond "I'm listening to [#{@listening.join(", ")}]", dest
760
762
  if ON_MASTER_BOT and ADMIN_USERS.include?(from)
761
- @bots_created.each { |key, value|
762
- respond "#{key}: #{value}", dest
763
- }
763
+
764
+ @bots_created.each do |k,v|
765
+ msg = []
766
+ msg << "`#{v[:channel_name]}` (#{k}):"
767
+ msg << "\tcreator: #{v[:creator_name]}"
768
+ msg << "\tadmins: #{v[:admins]}"
769
+ msg << "\tstatus: #{v[:status]}"
770
+ msg << "\tcreated: #{v[:created]}"
771
+ msg << "\trules: #{v[:rules_file]}"
772
+ msg << "\textended: #{v[:extended]}"
773
+ msg << "\tcloud: #{v[:cloud]}"
774
+ if ON_MASTER_BOT and v.key?(:cloud) and v[:cloud]
775
+ msg << "\trunner: `ruby #{$0} \"#{v[:channel_name]}\" \"#{v[:admins]}\" \"#{v[:rules_file]}\" on&`"
776
+ end
777
+ respond msg.join("\n"), dest
778
+ end
764
779
  end
765
780
  end
766
781
 
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.9.0
4
+ version: 0.9.1
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-27 00:00:00.000000000 Z
11
+ date: 2019-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slack-ruby-client
@@ -34,22 +34,16 @@ dependencies:
34
34
  name: async-websocket
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 0.8.0
40
37
  - - "~>"
41
38
  - !ruby/object:Gem::Version
42
- version: '0.8'
39
+ version: 0.8.0
43
40
  type: :runtime
44
41
  prerelease: false
45
42
  version_requirements: !ruby/object:Gem::Requirement
46
43
  requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 0.8.0
50
44
  - - "~>"
51
45
  - !ruby/object:Gem::Version
52
- version: '0.8'
46
+ version: 0.8.0
53
47
  description: "Create a Slack bot that is smart and so easy to expand, create new bots
54
48
  on demand, run ruby code on chat, create shortcuts... \n The main scope of this
55
49
  gem is to be used internally in the company so teams can create team channels with