lita-idobata 0.2.2 → 0.2.3

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: e7e5cf6267cb7a72a8a7aaed0f0f36efa28fed7a
4
- data.tar.gz: 6eedf45362ed115b3a20165e7127ea0ae235b748
3
+ metadata.gz: 36c42052b763a441cc33f94e38629f7fbae469d2
4
+ data.tar.gz: 55ba52535316332dae34a57961994a05d2906fef
5
5
  SHA512:
6
- metadata.gz: be8ddcc2d9e63d3bcba6bac5220e3f9c802cef76c4cfadc04d8ff29b3e38ad9f2b93976da79723d32a2508408a4c2cd9e0d65abc9b46a5835f6f93281d662b39
7
- data.tar.gz: f83564a622e4e22a4c3bc165091dbf8d95de0b486260c4fb60e7797e698a4c4a2e1842da2dee9ffcc31f72bd16719412c8b9ba422b9c27050cba8be0ea118b96
6
+ metadata.gz: 4f08f8ddbd3f0b39ff0b0d21a91b338a51e2ab3547c0feaaa7867ec1e37cb0e53a072eecdda8bb74de9b65d82a1b13ec2fa087681cb16d5cb979f6ac2ea1404a
7
+ data.tar.gz: 87e6ccbcd9591319d645bb1539d9f4e55fee88650b4eee9c06cb226cf3bcbca1a293dcacc948fb4ace2ea0f3614d2c2377d854fd847d7ee713bd360840a36fd0
@@ -42,7 +42,7 @@ module Lita
42
42
  socket.bind('message:created') do |data|
43
43
  message = JSON.parse(data)["message"]
44
44
  if message["sender_id"] != @bot['id']
45
- user = User.new(message["sender_id"], name: message["sender_name"])
45
+ user = find_user(*message.values_at('sender_id', 'sender_name', 'sender_type'))
46
46
  source = Source.new(user: user, room: message["room_id"])
47
47
  # `message["body_plain"]` is nil on image upload
48
48
  message = Message.new(robot, message["body_plain"].to_s, source)
@@ -71,6 +71,13 @@ module Lita
71
71
 
72
72
  private
73
73
 
74
+ def find_user(id, name, type)
75
+ # hook has no personality, it's only a machine
76
+ return User.new(id, name: name) if type == 'HookEndpoint'
77
+
78
+ User.find_by_id(id) || User.create(id, name: name)
79
+ end
80
+
74
81
  def auth_method
75
82
  -> (socket_id, channel) {
76
83
  response = http_client.post "/pusher/auth", { channel_name: channel.name, socket_id: socket_id }
@@ -1,5 +1,5 @@
1
1
  module Lita
2
2
  module Idobata
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-idobata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - fukayatsu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-10 00:00:00.000000000 Z
11
+ date: 2015-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita