Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message type: mini program for Message.type() #1444

Closed
kis87988 opened this issue Jul 5, 2018 · 5 comments
Closed

Message type: mini program for Message.type() #1444

kis87988 opened this issue Jul 5, 2018 · 5 comments

Comments

@kis87988
Copy link
Contributor

kis87988 commented Jul 5, 2018

Provide Your Network Information

  1. Where is the location of your server? (i.e. City, or In/Out China) U.S.
  2. Which cloud platform(AliYun/Qcloud/DigitalOcean/etc) are you using? self

docker

Expected behavior

Message.type() should have type check for mini program.

Actual behavior

Not implement yet

Steps to reproduce the behavior (and fixes, if any)

right now, I use regex to check content

/<appmsg appid=/gmi.test(content)

Full Output Logs

$ WECHATY_LOG=silly npm run ts-node mybot.ts

# or 

$ WECHATY_LOG=silly node dist/mybot.js
Show Logs

Paste the full output logs here with WECHATY_LOG=silly set

# PASTE FULL LOG OUTPUT AT HERE:
22:56:31 SILL PuppetPadchat messagePayload({"id":"8504300561420810805","timestamp":1530770190,"type":1,"filename":"8504300561420810805-to-be-implement.txt","fromId":"x","toId":"x","text":"<?xml version=\"1.0\"?>\n<msg>\n\t<appmsg appid=\"\" sdkver=\"0\">\n\t\t<title>这游戏也太虐了,我为什么要手贱点进来…</title>\n\t\t<des>欢乐球球</des>\
n\t\t<action />\n\t\t<type>33</type>\n\t\t<showtype>0</showtype>\n\t\t<soundtype>0</soundtype>\n\t\t<mediatagname />\n\t\t<messageext />\n\t\t<messageaction />\n\t\t<content />\n\t\t<contentattr>0</contentattr>\n\t\t<url>https://mp.weixin.qq.com/mp/waerrpage?appid=wxf872ea5294e051c0&amp;type=upgrade&amp;upgradetype=3#wechat_redirect</url>\n\t\t<lowurl />\n\t\t<dataurl />\n\t\t<lowdataurl />\n\t\t<appattach>\n\t\t\t<totallen>0</totallen>\n\t\t\t<attachid />\n\t\t\t<emoticonmd5 />\n\t\t\t<fileext />\n\t\t\t<cdnthumburl>30570201000450304e02010002042688e57e020310d95f020422c1cdcb02045b3d923a0429777875706c6f61645f323430333134383037304063686174726f6f6d33325f313533303736313738360204010c00030201000400</cdnthumburl>\n\t\t\t<cdnthumbmd5>29122ca0d74fa417d9fb0f3e8ce22f6d</cdnthumbmd5>\n\t\t\t<cdnthumblength>148375</cdnthumblength>\n\t\t\t<cdnthumbwidth>750</cdnthumbwidth>\n\t\t\t<cdnthumbheight>586</cdnthumbheight>\n\t\t\t<cdnthumbaeskey>b81c5d7468d141168e1fda1baf6c7d2b</cdnthumbaeskey>\n\t\t\t<aeskey>b81c5d7468d141168e1fda1baf6c7d2b</aeskey>\n\t\t\t<encryver>0</encryver>\n\t\t\t<filekey>x</filekey>\n\t\t</appattach>\n\t\t<extinfo />\n\t\t<sourceusername>gh_c7d9baff425d@app</sourceusername>\n\t\t<sourcedisplayname>欢乐球球</sourcedispl
ayname>\n\t\t<thumburl />\n\t\t<md5 />\n\t\t<statextstr />\n\t\t<weappinfo>\n\t\t\t<username><![CDATA[gh_c7d9baff425d@app]]></username>\n\t\t\t<appid><![CDATA[wxf872ea5294e051c0]]></appid>\n\t\t\t<type>3</type>\n\t\t\t<version>65</version>\n\t\t\t<weappiconurl><![CDATA[http://mmbiz.qpic.cn/mmbiz_png/SB3eCkicPyC3Ap7MJ98018RB6nJf7Zp1u9567qoE4fKlzbCgH6MYBKibyhdrfUGibgv8icfQvgfd6qlrW2aowNe1icw/0?wx_fmt=png]]></weappiconurl>\n\t\t\t<pagepath><![CDATA[?fuid=28853037&time=1530770187066]]></pagepath>\n\t\t\t<shareId><![CDATA[0_wxf872ea5294e051c0_2937303420_1530770189_0]]></shareId>\n\t\t\t<sharename><![CDATA[x]]></sharename>\n\t\t\t<appservicetype>4</appservicetype>\n\t\t</weappinfo>\n\t</appmsg>\n\t<fromusername>x</fromusername>\n\t<scene>0</scene>\n\t<appinfo>\n\t\t<version>1</version>\n\t\t<appname></appname>\n\t</appinfo>\n\t<commenturl></commenturl>\n</msg>\n"})
@huan
Copy link
Member

huan commented Jul 11, 2018

Do you have any suggestions about this, for example:

  1. What should the MessageType name be used for MiniProgram?
  2. Is there any ROBUST way for us to get to know the message is a mini-program?

@kis87988
Copy link
Contributor Author

currently, I check the content using /<appmsg appid=/gmi.test(content) && /@app/gmi.test(content) without any problem. and filter out all mini-program.

@suntong
Copy link
Contributor

suntong commented Jul 16, 2018

Is there any ROBUST way for us to get to know the message is a mini-program

I think it depends on the WECHATY_PUPPET, For padchat, it might be <appmsg appid=, but for traditional weichat, it is definately &lt;appmsg appid=. So maybe \bappmsg appid= works for both cases?

What should the MessageType name be used for MiniProgram?

I think it's better be called MiniApp, as what appmsg, appid etc hint for.

And I agreed that they should better be filtered out.
But on second thought. since urls are still normal messages, not of url type, I think they are better be dealt with both, or none.

Further, I'm writing a filter to decode them, so leaving them as normal messages works best for me though:

const wxmsg = '&lt;msg&gt;&lt;appmsg appid="" sdkver="0"&gt;&lt;title&gt;中国房价暴涨和中美贸易战的深层关系&lt;/title&gt;&lt;des&gt;本文原作是知乎的“奶包的大叔”在中国,2018刚刚进入5月,全国各地发布的...&lt;/des&gt;&lt;action&gt;&lt;/action&gt;&lt;type&gt;5&lt;/type&gt;'
wxmsg.replace(/.*&gt;&lt;title&gt;(.*)&lt;\/title&gt;&lt;des&gt;(.*)&lt;\/des&gt;&lt;.*/, "Title: $1\nDesc: $2\n")
// ->
Title: 中国房价暴涨和中美贸易战的深层关系
Desc: 本文原作是知乎的“奶包的大叔”在中国,2018刚刚进入5月,全国各地发布的...

@lvxuan263
Copy link

In the payload data of the APP message, there is a type field in the xml. It should be possible to distinguish the app message by type is URL/miniProgram/redpack/transfer, etc. The type field of the miniProgram is 36, and the type of the URL is 5.

@kis87988
Copy link
Contributor Author

Actually, I forgot to close this issue because the Padchat now is support. Refer to wechaty/wechaty-puppet-padchat#129.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants