relax-rb 0.2.3 → 0.3.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: cb5c87fed245878cc5486925f712ae43fb7d50c7
4
- data.tar.gz: 0e24b6c8918cc0ec82023f35dc0a8f14db12152b
3
+ metadata.gz: ff47f4362c674afc22b14b7e13481edca67aa4a4
4
+ data.tar.gz: d5edac2197381f64d121189fcfcab8ccacd45221
5
5
  SHA512:
6
- metadata.gz: 99e346584b383abbf8b708372dbfc14b56b8715e4e5ebac5dfb4791db8757175fd9579a67ba6e38148005ccae6d7191e13c861d6af04aabc9a0d3692307013f8
7
- data.tar.gz: a35905ab54d161bcbab08c7a91b12b64abd2ada57c256eda5d44b1e2dfd6a684e8b1ca7b203563df0aead2f1f5138162652a229604d436413e2f2bf364566d5f
6
+ metadata.gz: eaedfbe980d52309972e7da5579820bab1f5d0cab33cea78c8afa6dd766ad23639de3788487ed6783781708768b27d4d8fd5f38a6e50dcf82dac5377fe80423c
7
+ data.tar.gz: 1ce477fb55b0de05e454a231d7d557de84c35c1e28bd9e94db92fb26f9e8a799051801ef7467e941c9c9a776c532dc4e94a117524c1856a1ed7e293fd10e8588
data/lib/relax/bot.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'securerandom'
2
+
1
3
  module Relax
2
4
  class BotsKeyNotSetError < StandardError; end
3
5
  class BotsPubsubNotSetError < StandardError; end
@@ -20,6 +22,23 @@ module Relax
20
22
  end
21
23
  end
22
24
 
25
+ def self.start_typing!(team_uid, channel_uid)
26
+ if relax_bots_key.nil? || relax_bots_key == ""
27
+ raise BotsKeyNotSetError, "Environment Variable RELAX_BOTS_KEY is not set"
28
+ end
29
+
30
+ if relax_bots_pubsub.nil? || relax_bots_pubsub == ""
31
+ raise BotsPubsubNotSetError, "Environment Variable RELAX_BOTS_PUBSUB is not set"
32
+ end
33
+
34
+ message_id = SecureRandom.uuid
35
+ payload = { id: message_id, type: 'typing', channel: channel_uid }.to_json
36
+
37
+ redis.with do |conn|
38
+ conn.publish(relax_bots_pubsub, {type: 'message', team_id: team_uid, id: message_id, payload: payload}.to_json)
39
+ end
40
+ end
41
+
23
42
  def self.relax_bots_pubsub
24
43
  ENV['RELAX_BOTS_PUBSUB']
25
44
  end
data/lib/relax/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Relax
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.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.2.3
4
+ version: 0.3.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-02-22 00:00:00.000000000 Z
11
+ date: 2016-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis