Skip to content

Commit 66f61b4

Browse files
committed
Implement stickerResourceType property
implment #228
1 parent 361f7d4 commit 66f61b4

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

linebot/models/messages.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,22 @@ class StickerMessage(Message):
176176
For a list of basic LINE stickers and sticker IDs, see sticker list.
177177
"""
178178

179-
def __init__(self, id=None, package_id=None, sticker_id=None, **kwargs):
179+
def __init__(self, id=None, package_id=None, sticker_id=None,
180+
sticker_resource_type=None, **kwargs):
180181
"""__init__ method.
181182
182183
:param str id: Message ID
183184
:param str package_id: Package ID
184185
:param str sticker_id: Sticker ID
186+
:param str sticker_resource_type: Sticker resource type
185187
:param kwargs:
186188
"""
187189
super(StickerMessage, self).__init__(id=id, **kwargs)
188190

189191
self.type = 'sticker'
190192
self.package_id = package_id
191193
self.sticker_id = sticker_id
194+
self.sticker_resource_type = sticker_resource_type
192195

193196

194197
class FileMessage(Message):

tests/test_webhook.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def test_parse(self):
156156
self.assertEqual(events[5].message.type, 'sticker')
157157
self.assertEqual(events[5].message.package_id, '1')
158158
self.assertEqual(events[5].message.sticker_id, '1')
159+
self.assertEqual(events[5].message.sticker_resource_type, 'STATIC')
159160

160161
# FollowEvent, SourceUser
161162
self.assertIsInstance(events[6], FollowEvent)
@@ -452,6 +453,11 @@ def message_content(event):
452453
def message_sticker(event):
453454
self.assertEqual('message', event.type)
454455
self.assertEqual('sticker', event.message.type)
456+
self.assertIn(
457+
event.message.sticker_resource_type,
458+
['STATIC', 'ANIMATION', 'SOUND', 'ANIMATION_SOUND',
459+
'POPUP', 'POPUP_SOUND', 'NAME_TEXT']
460+
)
455461

456462
@self.handler.add(MessageEvent)
457463
def message(event):

tests/text/webhook.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@
9999
"id": "325708",
100100
"type": "sticker",
101101
"packageId": "1",
102-
"stickerId": "1"
102+
"stickerId": "1",
103+
"stickerResourceType": "STATIC"
103104
}
104105
},
105106
{

0 commit comments

Comments
 (0)