Skip to content

Commit 163bd86

Browse files
authored
feat: Support sticker message keywords (#305)
* feat: add keywords property * test: add sticker message keywords case * chore: add type hint Co-authored-by: louis70109 <louis70109@gmail.com>
1 parent b2c0d9d commit 163bd86

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

linebot/models/messages.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,14 @@ class StickerMessage(Message):
189189
"""
190190

191191
def __init__(self, id=None, package_id=None, sticker_id=None,
192-
sticker_resource_type=None, **kwargs):
192+
sticker_resource_type=None, keywords=None, **kwargs):
193193
"""__init__ method.
194194
195195
:param str id: Message ID
196196
:param str package_id: Package ID
197197
:param str sticker_id: Sticker ID
198198
:param str sticker_resource_type: Sticker resource type
199+
:param list[str] keywords: List of up to 15 keywords describing the sticker
199200
:param kwargs:
200201
"""
201202
super(StickerMessage, self).__init__(id=id, **kwargs)
@@ -204,6 +205,7 @@ def __init__(self, id=None, package_id=None, sticker_id=None,
204205
self.package_id = package_id
205206
self.sticker_id = sticker_id
206207
self.sticker_resource_type = sticker_resource_type
208+
self.keywords = keywords
207209

208210

209211
class FileMessage(Message):

tests/test_webhook.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ def test_parse(self):
168168
self.assertEqual(events[5].message.package_id, '1')
169169
self.assertEqual(events[5].message.sticker_id, '1')
170170
self.assertEqual(events[5].message.sticker_resource_type, 'STATIC')
171+
self.assertEqual(events[5].message.keywords[0], 'Love You')
172+
self.assertEqual(events[5].message.keywords[1], 'Love')
171173

172174
# FollowEvent, SourceUser
173175
self.assertIsInstance(events[6], FollowEvent)

tests/text/webhook.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@
106106
"type": "sticker",
107107
"packageId": "1",
108108
"stickerId": "1",
109-
"stickerResourceType": "STATIC"
109+
"stickerResourceType": "STATIC",
110+
"keywords": ["Love You", "Love"]
110111
}
111112
},
112113
{

0 commit comments

Comments
 (0)