Skip to content

Commit 05c39e7

Browse files
authored
Merge pull request #109 from line/feature/member_join_and_leave_event
Add memberJoined and memberLeft event
2 parents 04881af + 528dec6 commit 05c39e7

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed

lib/line/bot/event.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
require 'line/bot/event/message'
2222
require 'line/bot/event/postback'
2323
require 'line/bot/event/unfollow'
24+
require 'line/bot/event/member_joined'
25+
require 'line/bot/event/member_left'

lib/line/bot/event/member_joined.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2016 LINE
2+
#
3+
# LINE Corporation licenses this file to you under the Apache License,
4+
# version 2.0 (the "License"); you may not use this file except in compliance
5+
# with the License. You may obtain a copy of the License at:
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
15+
module Line
16+
module Bot
17+
module Event
18+
class MemberJoined < Base
19+
end
20+
end
21+
end
22+
end

lib/line/bot/event/member_left.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2016 LINE
2+
#
3+
# LINE Corporation licenses this file to you under the Apache License,
4+
# version 2.0 (the "License"); you may not use this file except in compliance
5+
# with the License. You may obtain a copy of the License at:
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
15+
module Line
16+
module Bot
17+
module Event
18+
class MemberLeft < Base
19+
end
20+
end
21+
end
22+
end

spec/line/bot/client_parse_spec.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,48 @@
158158
"result": "ok",
159159
"nonce": "nonce"
160160
}
161+
},
162+
{
163+
"type": "memberJoined",
164+
"replyToken": "replyToken",
165+
"source": {
166+
"type": "user",
167+
"groupId": "groupId"
168+
},
169+
"timestamp": 12345678901234,
170+
"joined": {
171+
"members": [
172+
{
173+
"type": "user",
174+
"userId": "U4af4980629..."
175+
},
176+
{
177+
"type": "user",
178+
"userId": "U91eeaf62d9..."
179+
}
180+
]
181+
}
182+
},
183+
{
184+
"type": "memberLeft",
185+
"replyToken": "replyToken",
186+
"source": {
187+
"type": "user",
188+
"groupId": "groupId"
189+
},
190+
"timestamp": 12345678901234,
191+
"left": {
192+
"members": [
193+
{
194+
"type": "user",
195+
"userId": "U4af4980629..."
196+
},
197+
{
198+
"type": "user",
199+
"userId": "U91eeaf62d9..."
200+
}
201+
]
202+
}
161203
}
162204
]
163205
}
@@ -268,6 +310,9 @@ def generate_client
268310
expect(events[12]).to be_a(Line::Bot::Event::AccountLink)
269311
expect(events[12].result).to eq("ok")
270312
expect(events[12].nonce).to eq("nonce")
313+
314+
expect(events[13]).to be_a(Line::Bot::Event::MemberJoined)
315+
expect(events[14]).to be_a(Line::Bot::Event::MemberLeft)
271316
end
272317

273318
it 'parses unknown event' do

0 commit comments

Comments
 (0)