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 +4 -4
- data/lib/ruboty/adapters/cww.rb +17 -4
- data/lib/ruboty/cww/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8807aa9ca16fc4f637a286283e8297510405fb7ec70b0c16e778b19cb39ccc1b
|
4
|
+
data.tar.gz: a6158e0e45965a0b9dcd7e4b6d8b8215941f7455d44976a8e951fa0f7fd10fde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89ae64fd25831a0c4b7e0ce287efdf67bfa00205dd08f04fdbd7de0f20cfcc5e536dd630dc39d6fbe190b549fcebb637f065542ce88c58efefad146e5b0c1d08
|
7
|
+
data.tar.gz: 79ac9cbab01694da5f90d43a16c6e69fb059e15ebf9d13c4281afc8175211c313158ce95d1a7fac35bd0c74186942c3b144081a1cab6fee1c05813e33680a539
|
data/lib/ruboty/adapters/cww.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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)
|
data/lib/ruboty/cww/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2018-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|