ruboty-line_bot 0.1.0 → 0.1.1

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: fd9cfd072d11e2014a753b46c4276acaf0718af4
4
- data.tar.gz: 0513a4fff707692bb896e5fc1bc1a244727357b8
3
+ metadata.gz: c4b6fe36c1ecb277e596e83f967fe15cb7502dd2
4
+ data.tar.gz: bbd2a46f1359bb2b661b8cb05bc7d20d59eb9c85
5
5
  SHA512:
6
- metadata.gz: 8280e03f66aa54298162d69cbd825caf394b3abb16d59de6cc85eb4f95f59ed8c53617fc5560b6ece8ead60726208c2e82456324f5564861062c966506f52a12
7
- data.tar.gz: 9fdd71fa0e1da33db9b76dd9b5da86a68787b581871a78e56863fb80e357d92acd2e6c7e9db0638b7bbdaa05f48e8553381ba08b3e8b4cff6e00abb481e2bc66
6
+ metadata.gz: a1b7a575200b88543bd6ae7f546325a716cb4ad8cbfd1e7802a57cf32377b167ff42b635c2d07f917b1608f0e8a7d86b720a7c19acb3688f3b6f574caffd2914
7
+ data.tar.gz: 7dc08ecc98fb30cca37e1f4226bebe121d4bd1165289edddb647a56ad0bb01f07fd79a1ce8f25f0790e5f7b12b2639a92d4f9c116bba16430b10c3bf2df3e07f
data/README.md CHANGED
@@ -16,5 +16,5 @@ LINE_CHANNEL_MID - LINE Channel MID
16
16
  LINE_SERVER_BIND_ADDRESS - Bind address (default: 0.0.0.0)
17
17
  LINE_SERVER_PORT - Port (default: 4567)
18
18
  LINE_SERVER_ENDPOINT - Endpoint (default: /callback)
19
- RESPOND_TO_ALL - Pass 1 to force ruboty to respond all message without mention
19
+ RESPOND_TO_ALL - Pass 1 to force ruboty to respond all messages without mention
20
20
  ```
@@ -1,6 +1,6 @@
1
1
  module Ruboty
2
2
  class Action
3
- # return true to respond every message without robot name.
3
+ # return true to respond every messages without robot name.
4
4
  def all?
5
5
  true
6
6
  end
@@ -20,6 +20,7 @@ module Ruboty
20
20
 
21
21
  def init
22
22
  @queue = Queue.new
23
+ @cached_contacts = {}
23
24
  end
24
25
 
25
26
  def say(message)
@@ -84,11 +85,26 @@ module Ruboty
84
85
 
85
86
  keys = [:id, :from_mid, :to_mid, :from_channel_id, :to_channel_id, :event_type, :created_time, :content]
86
87
  message = keys.each_with_object({}) {|key, hash| hash[key] = event.send(key) }
88
+
89
+ unless contact = @cached_contacts[message[:from_mid]]
90
+ contact = client.get_user_profile(message[:from_mid]).contacts.first
91
+ @cached_contacts.update({
92
+ contact.mid => {
93
+ mid: contact.mid,
94
+ display_name: contact.display_name,
95
+ picture_url: contact.picture_url,
96
+ status_message: contact.status_message,
97
+ }
98
+ })
99
+ contact = @cached_contacts[contact.mid]
100
+ end
101
+
87
102
  message.update(
88
- body: message[:content].content[:text],
89
- from: message[:from_mid],
90
- to: message[:to_mid],
91
- type: message[:event_type],
103
+ body: message[:content].content[:text],
104
+ from: message[:from_mid],
105
+ from_name: contact[:display_name],
106
+ to: message[:to_mid],
107
+ type: message[:event_type],
92
108
  )
93
109
  Ruboty.logger.debug('Received:' + message.inspect)
94
110
  robot.receive(message)
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module LineBot
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-line_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - meganemura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-09 00:00:00.000000000 Z
11
+ date: 2016-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruboty