slack-smart-bot 0.8.3 → 0.9.0

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 +12 -0
  3. data/lib/slack-smart-bot.rb +19 -10
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a068b59198e7c02bdf9c58f9b694699a550034540848de56e39e17cea9c7cf40
4
- data.tar.gz: 12ac140c01e5f7cda57373b45960fa6fb1c9ebbbf7afdae96da3435b2f0c6277
3
+ metadata.gz: f35296a4d203ca6571478d139003f5f17741d07a815718f8e024cc9e077a482a
4
+ data.tar.gz: 9817c32b14938cf57464fe34d151836f3889843e2216c23b5f192da3a24bee5c
5
5
  SHA512:
6
- metadata.gz: f682eff80b6ee14339b44706708516b406a5a3ba23529be7e3174d15e96f36b9fc37cd926afff138d0927de6e9cd30fbd7d6c6086cd50ec624beb56dc98fb21d
7
- data.tar.gz: c6123c515cabb71da6477526ba4cb312755d2057e29e679c751987fb586cddbd2a0a501e9bbd89c9e4bf4c514db9c8eb7c0e9f7e2536b7d3cba6b0b30314d75b
6
+ metadata.gz: 3ec6d3a625b4df6d6c10d96f49aba96c7b07a1b2bc03425b32c0187a35bb89b2c493b394663eb6e50430c19d6eb5fa8225f63d4960c478e0374471a11fc06873
7
+ data.tar.gz: f9f76944a778989144e524dd5f40e53a37109ffa8f6ec1e613d70f9a68aa79ca324b9698d806e6ef8bf4003b0f2fb8eeafdaaab2027f0b68436c14fc5c784fed
data/README.md CHANGED
@@ -308,6 +308,18 @@ Apart of the specific commands you define on the rules file of the channel, you
308
308
 
309
309
  >Also you can use this command to call another bot from a channel with a running bot.
310
310
 
311
+ ### Creating cloud bots
312
+
313
+ If you need to run a channel bot from a different machine you can use the command:
314
+
315
+ **_`create cloud bot on #CHANNEL_NAME`_**
316
+
317
+ After that you will need to copy your current Smart Bot folder into the the new location. Install all you need: Ruby, slack-smart-bot... and run the command supplied by the Smart Bot after you run the `create cloud` command.
318
+
319
+ The new cloud bot will be managed by your Master Bot like the others, closing, pausing...
320
+
321
+ This is very useful when you need to run certain processes on a different environment for example on a Windows machine while your Master Bot is on Ubuntu.
322
+
311
323
  ## Contributing
312
324
 
313
325
  Bug reports and pull requests are welcome on GitHub at https://github.com/marioruiz/slack-smart-bot.
@@ -68,11 +68,13 @@ class SlackSmartBot
68
68
  get_bots_created()
69
69
  if @bots_created.kind_of?(Hash)
70
70
  @bots_created.each { |key, value|
71
- @logger.info "ruby #{$0} \"#{value[:channel_name]}\" \"#{value[:admins]}\" \"#{value[:rules_file]}\" #{value[:status].to_sym}"
72
- t = Thread.new do
73
- `ruby #{$0} \"#{value[:channel_name]}\" \"#{value[:admins]}\" \"#{value[:rules_file]}\" #{value[:status].to_sym}`
71
+ if !value.key?(:cloud) or (value.key?(:cloud) and value[:cloud] == false)
72
+ @logger.info "ruby #{$0} \"#{value[:channel_name]}\" \"#{value[:admins]}\" \"#{value[:rules_file]}\" #{value[:status].to_sym}"
73
+ t = Thread.new do
74
+ `ruby #{$0} \"#{value[:channel_name]}\" \"#{value[:admins]}\" \"#{value[:rules_file]}\" #{value[:status].to_sym}`
75
+ end
76
+ value[:thread] = t
74
77
  end
75
- value[:thread] = t
76
78
  }
77
79
  end
78
80
  end
@@ -206,7 +208,7 @@ class SlackSmartBot
206
208
  if data.text.match(/^<@#{config[:nick_id]}>\s(on\s)?<#(\w+)\|(.+)>\s*:?\s*(.*)/im)
207
209
  channel_rules = $2
208
210
  channel_rules_name = $3
209
- #to be treated only on the bot of the requested channel
211
+ # to be treated only on the bot of the requested channel
210
212
  if @channel_id == channel_rules
211
213
  data.text = $4
212
214
  typem = :on_call
@@ -791,13 +793,15 @@ class SlackSmartBot
791
793
 
792
794
  #helpmaster: ----------------------------------------------
793
795
  #helpmaster: `create bot on CHANNEL_NAME`
796
+ #helpmaster: `create cloud bot on CHANNEL_NAME`
794
797
  #helpmaster: creates a new bot on the channel specified
795
798
  #helpmaster: it will work only if you are on Master channel
796
799
  #helpmaster: the admins will be the master admins, the creator of the bot and the creator of the channel
797
- #helpmaster:
798
- when /^create\sbot\son\s<#C\w+\|(.+)>\s*/i, /^create\sbot\son\s(.+)\s*/i
800
+ #helpmaster: follow the instructions in case creating cloud bots
801
+ when /^create\s+(cloud\s+)?bot\s+on\s+<#C\w+\|(.+)>\s*/i, /^create\s+(cloud\s+)?bot\s+on\s+(.+)\s*/i
799
802
  if ON_MASTER_BOT
800
- channel = $1
803
+ cloud = !$1.nil?
804
+ channel = $2
801
805
 
802
806
  get_channels_name_and_id() unless @channels_name.keys.include?(channel) or @channels_id.keys.include?(channel)
803
807
  channel_id = nil
@@ -838,8 +842,12 @@ class SlackSmartBot
838
842
  admin_users = [from, creator_info.user.name] + MASTER_USERS
839
843
  admin_users.uniq!
840
844
  @logger.info "ruby #{$0} \"#{channel}\" \"#{admin_users.join(",")}\" \"#{rules_file}\" on"
841
- t = Thread.new do
842
- `ruby #{$0} \"#{channel}\" \"#{admin_users.join(",")}\" \"#{rules_file}\" on`
845
+ if cloud
846
+ respond "Copy the bot folder to your cloud location and run `ruby #{$0} \"#{channel}\" \"#{admin_users.join(",")}\" \"#{rules_file}\" on&`", dest
847
+ else
848
+ t = Thread.new do
849
+ `ruby #{$0} \"#{channel}\" \"#{admin_users.join(",")}\" \"#{rules_file}\" on`
850
+ end
843
851
  end
844
852
  @bots_created[channel_id] = {
845
853
  creator_name: from,
@@ -850,6 +858,7 @@ class SlackSmartBot
850
858
  rules_file: rules_file,
851
859
  admins: admin_users.join(","),
852
860
  extended: [],
861
+ cloud: cloud,
853
862
  thread: t,
854
863
  }
855
864
  respond "The bot has been created on channel: #{channel}. Rules file: #{File.basename rules_file}. Admins: #{admin_users.join(", ")}", dest
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-smart-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz