Skip to content

Commit

Permalink
feat: Add new customer service message type miniprogrampage (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
tssujt authored and messense committed Mar 16, 2021
1 parent bc93067 commit 635271a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,26 @@ def test_link_message(self):
self.assertEqual("test", msg.title)
self.assertEqual("test", msg.description)
self.assertEqual("http://www.qq.com", msg.url)

def test_miniprogrampage_message(self):
from wechatpy.messages import MiniProgramPageMessage

msg = MiniProgramPageMessage(
{
"ToUserName": "toUser",
"FromUserName": "fromUser",
"CreateTime": 1482048670,
"MsgType": "miniprogrampage",
"MsgId": 1234567890123456,
"Title": "title",
"AppId": "appid",
"PagePath": "path",
"ThumbUrl": "thumburl",
"ThumbMediaId": "thumbmediaid",
}
)
self.assertEqual("appid", msg.app_id)
self.assertEqual("title", msg.title)
self.assertEqual("path", msg.page_path)
self.assertEqual("thumburl", msg.thumb_url)
self.assertEqual("thumbmediaid", msg.thumb_media_id)
16 changes: 16 additions & 0 deletions wechatpy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ class LinkMessage(BaseMessage):
url = StringField("Url")


@register_message("miniprogrampage")
class MiniProgramPageMessage(BaseMessage):
"""
小程序卡片消息
详情请参阅
https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/receive.html#小程序卡片消息
"""

type = "miniprogrampage"
app_id = StringField("AppId")
title = StringField("Title")
page_path = StringField("PagePath")
thumb_url = StringField("ThumbUrl")
thumb_media_id = StringField("ThumbMediaId")


class UnknownMessage(BaseMessage):
"""未知消息类型"""

Expand Down

0 comments on commit 635271a

Please sign in to comment.