relax-rb 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4832c9e281f3c41551238d7799966be0a976cb26
4
- data.tar.gz: fb7959825fc214697cc2cbf94aaf5a8aa4f2ac61
3
+ metadata.gz: 6db0a2f9081c519b5353d64e5992a963f6a507f6
4
+ data.tar.gz: b8db0561ca5c0e3d069946931f7213493f8ea056
5
5
  SHA512:
6
- metadata.gz: a56a7bef5fb9cc82a23827e407b18e4976e68d816a3891e793fb5cf39f006b24ba58215cf7113c81d20accbe8fb313edfca6c4109e633efb279ca266fc1bed7e
7
- data.tar.gz: d89fe67613ff50e48c6b2691b68d547f979c2a4fba7be8257392d867c99ec43230b98f6c394ed679115bbcbfa2bf110d2c6262db7dd759c49d90511a74b651b5
6
+ metadata.gz: b487822f834f559b763bce5b64dade1cccbc23d03bb99dd1d3402e17fd39fac801efaeb4878471e26ecdc8e1ab8c4e0b8735ca58e8a06b92f64255eb666c7c82
7
+ data.tar.gz: dfbf8eee7a430e5cb86b6539d55ca2f77ce69a6c5a5f8232454c2aa6c582da41fdc2ec3a320f820b2b0e231944e9830adbdc54533d96c91009b47f0110849f5f
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "relax/rb"
4
+ require "relax"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
data/lib/relax/bot.rb CHANGED
@@ -29,6 +29,28 @@ module Relax
29
29
  end
30
30
  end
31
31
 
32
+ def self.stop!(team_uid, opts = {})
33
+ if relax_bots_key.nil? || relax_bots_key == ""
34
+ raise BotsKeyNotSetError, "Environment Variable RELAX_BOTS_KEY is not set"
35
+ end
36
+
37
+ if relax_bots_pubsub.nil? || relax_bots_pubsub == ""
38
+ raise BotsPubsubNotSetError, "Environment Variable RELAX_BOTS_PUBSUB is not set"
39
+ end
40
+
41
+ namespace = (opts[:namespace] || opts['namespace']).to_s.strip
42
+ key = namespace == "" ? team_uid : "#{namespace}-#{team_uid}"
43
+ pubsub_payload = {type: 'team_removed', team_id: team_uid}
44
+ pubsub_payload.merge!(namespace: namespace) if namespace != ""
45
+
46
+ redis.with do |conn|
47
+ conn.multi do
48
+ conn.hdel(relax_bots_key, key)
49
+ conn.publish(relax_bots_pubsub, pubsub_payload.to_json)
50
+ end
51
+ end
52
+ end
53
+
32
54
  def self.start_typing!(team_uid, channel_uid)
33
55
  if relax_bots_key.nil? || relax_bots_key == ""
34
56
  raise BotsKeyNotSetError, "Environment Variable RELAX_BOTS_KEY is not set"
data/lib/relax/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Relax
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relax-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - arunthampi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-27 00:00:00.000000000 Z
11
+ date: 2016-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis