lita-glip 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5502fc959b164039fdc5c227593cbf583854a331
4
- data.tar.gz: ba5093333f9daebf33583b7653aa7269b73579fa
3
+ metadata.gz: 24cf9ba2a53b998c09309a760784a879df6a31bb
4
+ data.tar.gz: e57d9f01b71ec6ed7b3f6ca7df6f6eb316110f27
5
5
  SHA512:
6
- metadata.gz: 9c28ea9fd3e95050e0a3caa48ae03580045733b7d55f4e1dc423778b0b1df6075b64a5dbd0cabca3dd4bb93ac63e054a4324c62affdfd4ee6453588f3929a618
7
- data.tar.gz: 598a57788ff1752e2af72c1b731981b5844fadb70ab80b4218c697aa938928737e756715a883ee32f803081cd4adabef6f2777464132adc952321c14e51e3790
6
+ metadata.gz: ac47c33a7ee493a2b9a77416bc7da465eac3c324b2f4ec86c0a9f70506ed1d152bf0a391453ca270250d9f16eca23b7c7ec1f48b22287464961cd61f65f39b33
7
+ data.tar.gz: 1217eb97ffe1ebee95e65057f135e2117a68892947949aaf59a29e6e88fec184bff606e253afbe9c22660bb85eebc45de2e53c5762f7647ca4a7676375831c1b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  CHANGELOG
2
2
  ---------
3
+ - **2017-04-01**: 0.1.0
4
+ - add updated message event support
3
5
  - **2017-03-14**: 0.0.4
4
6
  - add debug level logging to `MessageHandler::update`
5
7
  - **2017-03-13**: 0.0.3
@@ -49,6 +49,7 @@ module Lita
49
49
 
50
50
  def message(group_id, strings)
51
51
  strings.each do |s|
52
+ Lita.logger.debug("#{@logger_prefix}Send Message To Glip From Lita: #{s}.")
52
53
  @glip_sdk.posts.post groupId: group_id, text: s
53
54
  end
54
55
  end
@@ -4,6 +4,9 @@ module Lita
4
4
  module Adapters
5
5
  class Glip < Adapter
6
6
  class MessageHandler
7
+ TYPE_PROPERTY_A = 'eventType'
8
+ TYPE_PROPERTY_B = 'messageType'
9
+
7
10
  attr_reader :robot
8
11
 
9
12
  def initialize(robot, glip_sdk)
@@ -21,18 +24,26 @@ module Lita
21
24
  return
22
25
  end
23
26
 
24
- unless m.key?('body') && m['body'].key?('messageType') && m['body']['messageType'] == "PostAdded"
27
+ unless m.key?('body')
28
+ Lita.logger.warn("#{@logger_prefix}Glip Lita: Glip Message Received without body: #{MultiJson.encode(m)}")
25
29
  return
26
30
  end
27
31
 
28
- user_id = message['body']['post']['creatorId']
32
+ unless (m['body'].key?(TYPE_PROPERTY_A) && m['body'][TYPE_PROPERTY_A] == "PostAdded") ||
33
+ (m['body'].key?(TYPE_PROPERTY_B) && m['body'][TYPE_PROPERTY_B] == "PostAdded")
34
+ return
35
+ end
36
+
37
+ post = m['body'].key?('post') ? m['body']['post'] : m['body']
38
+
39
+ user_id = post['creatorId']
29
40
  user = UserCreator.find_or_create_user user_id, @glip_sdk
30
41
 
31
- room_id = message['body']['post']['groupId']
42
+ room_id = post['groupId']
32
43
  room = RoomCreator.find_or_create_room room_id, @glip_sdk
33
44
 
34
45
  source = Lita::Source.new user: user, room: room
35
- post = message['body']['post']['text'].to_s
46
+ post = post['text'].to_s
36
47
  msg = Lita::Message.new @robot, post, source
37
48
 
38
49
  Lita.logger.debug("#{@logger_prefix}Glip Lita: Robot Message Built")
data/lita-glip.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-glip'
3
- spec.date = '2017-03-14'
4
- spec.version = '0.0.4'
3
+ spec.date = '2017-04-01'
4
+ spec.version = '0.1.0'
5
5
  spec.authors = ['John Wang']
6
6
  spec.email = ["johncwang@gmail.com"]
7
7
  spec.description = %q{A Glip adapter for Lita.}
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ['lib']
18
18
 
19
19
  spec.add_runtime_dependency 'lita', '~> 4', '>= 4.4.3'
20
- spec.add_runtime_dependency 'glip_sdk', '~> 0', '>= 0.0.3'
20
+ spec.add_runtime_dependency 'glip_sdk', '~> 0', '>= 0.0.5'
21
21
  spec.add_runtime_dependency 'multi_json', '~> 1', '>= 1.12.1'
22
22
 
23
23
  spec.add_development_dependency 'bundler', '~> 1.3'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-glip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-14 00:00:00.000000000 Z
11
+ date: 2017-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '0'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.0.3
42
+ version: 0.0.5
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '0'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 0.0.3
52
+ version: 0.0.5
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: multi_json
55
55
  requirement: !ruby/object:Gem::Requirement