ruboty-cww 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
  SHA256:
3
- metadata.gz: '039ab7530bb9a0f535b28a283f6cd85bd1645b4996c8110957518ce652440fd4'
4
- data.tar.gz: 0b4268dd8a062a939e9cd62cc026d11122c4857a652a4c37cc7b1e1a000e8908
3
+ metadata.gz: 8807aa9ca16fc4f637a286283e8297510405fb7ec70b0c16e778b19cb39ccc1b
4
+ data.tar.gz: a6158e0e45965a0b9dcd7e4b6d8b8215941f7455d44976a8e951fa0f7fd10fde
5
5
  SHA512:
6
- metadata.gz: 2a96d73ffbc3816d033b4b5e6ee21b935b644a44ea41e1e44f5744c01e80fb8aa6f8243ae0082fec274c423e44f872ab1b887a2c395cbaa83efd829b549feb4a
7
- data.tar.gz: e0b9f909a99fd90ce7df86390108254b65833c6bf894f68a974e3d82978122fd204173dcbb1b75530af2c732344c0a8a1e4703b2a28f431f38e07601781de57e
6
+ metadata.gz: 89ae64fd25831a0c4b7e0ce287efdf67bfa00205dd08f04fdbd7de0f20cfcc5e536dd630dc39d6fbe190b549fcebb637f065542ce88c58efefad146e5b0c1d08
7
+ data.tar.gz: 79ac9cbab01694da5f90d43a16c6e69fb059e15ebf9d13c4281afc8175211c313158ce95d1a7fac35bd0c74186942c3b144081a1cab6fee1c05813e33680a539
@@ -25,7 +25,7 @@ module Ruboty
25
25
  req.body = JSON.generate(post_message_data(message))
26
26
  https = Net::HTTP.new(url.host, access_port)
27
27
  https.use_ssl = true
28
- res = https.start {|https| https.request(req) }
28
+ res = https.start { |https| https.request(req) }
29
29
  end
30
30
 
31
31
  private
@@ -33,7 +33,8 @@ module Ruboty
33
33
  def init
34
34
  ENV["RUBOTY_NAME"] ||= bot_user_name
35
35
  @last_created_at_from = "0"
36
- get_messages
36
+ @last_fetch_message_ids = []
37
+ set_last_fetch_message_ids(get_messages)
37
38
  end
38
39
 
39
40
  def listen
@@ -48,7 +49,7 @@ module Ruboty
48
49
  req = Net::HTTP::Get.new(url.request_uri, headers)
49
50
  https = Net::HTTP.new(url.host, access_port)
50
51
  https.use_ssl = true
51
- res = https.start {|https| https.request(req)}
52
+ res = https.start { |https| https.request(req) }
52
53
  messages = JSON.parse(res.body)["messages"]
53
54
  messages = messages.sort_by { |hash| hash['createdAt'].to_i }
54
55
  unless messages.last.nil?
@@ -62,16 +63,28 @@ module Ruboty
62
63
  end
63
64
 
64
65
  def listen_group
65
- get_messages.each do |m|
66
+ messages = get_messages
67
+ messages.each do |m|
66
68
  if m["createdBy"] === bot_user_id
67
69
  next
68
70
  end
71
+ if @last_fetch_message_ids.include?(m["messageId"])
72
+ next
73
+ end
69
74
 
70
75
  # botに送りたい情報を設定
71
76
  robot.receive(
72
77
  body: m["text"]
73
78
  )
74
79
  end
80
+ set_last_fetch_message_ids(messages)
81
+ end
82
+
83
+ def set_last_fetch_message_ids(messages)
84
+ @last_fetch_message_ids = []
85
+ messages.each do |m|
86
+ @last_fetch_message_ids << m["messageId"]
87
+ end
75
88
  end
76
89
 
77
90
  def post_message_data(message)
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Cww
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-cww
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
  - DreamArts Corporation.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-14 00:00:00.000000000 Z
11
+ date: 2018-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruboty