-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Discussion of switching GetContactPayload to SearchContactPayload #1397
Comments
Related to #1358 |
Yes, Because in PuppetPadchat it will fail when getting a contact payload for a stranger in the room, so your discussion is very valuable for us to deal with the Pachat protocol well. My suggestion would be:
|
@windmemory I change my code as follows here in /**
* Get contact by contact id
* @param {any} id user_name
*/
public async WXGetContactPayload(id: string): Promise<PadchatContactPayload> {
if (!isContactId(id)) { // /@chatroom$/.test(id)) {
throw Error(`should use WXGetRoomPayload because get a room id :${id}`)
}
let result = await this.WXGetContact(id) as PadchatContactPayload
if (!result.user_name) {
result = await this.WXSearchContact(id) as PadchatContactPayload
}
return result
} Well, the API is blocked... Related log as follows: 01:45:53 INFO PadchatRpc WXSearchContact wxid: wxid_pmct091suwyt12 cannot be searched
01:45:53 SILL PuppetPadchat contactRawPayloadParser({user_name=""})
01:45:53 ERR Contact ready() this.puppet.contactPayload(Contact) exception: cannot get user_name from raw payload: {"big_head":"","city":"","country":"","message":"\n�\u0002<e>\n<ShowType>1</ShowType>\n<Content><![CDATA[找不到相关帐号或内容]]></Content>\n<Url><![CDATA[]]></Url>\n<DispSec>30</DispSec>\n<Title><![CDATA[]]></Title>\n<Action>2</Action>\n<DelayConnSec>0</DelayConnSec>\n<Countdown>0</Countdown>\n<Ok><![CDATA[]]></Ok>\n<Cancel><![CDATA[]]></Cancel>\n</e>\n","nick_name":"","provincia":"","py_initial":"","quan_pin":"","sex":0,"signature":"","small_head":"","status":-24,"stranger":"","user_name":""}
01:45:53 SILL PadchatRpc WXSearchContact result: {"big_head":"","city":"","country":"","message":"\n�\u0002<e>\n<ShowType>1</ShowType>\n<Content><![CDATA[找不到相关帐号或内容]]></Content>\n<Url><![CDATA[]]></Url>\n<DispSec>30</DispSec>\n<Title><![CDATA[]]></Title>\n<Action>2</Action>\n<DelayConnSec>0</DelayConnSec>\n<Countdown>0</Countdown>\n<Ok><![CDATA[]]></Ok>\n<Cancel><![CDATA[]]></Cancel>\n</e>\n","nick_name":"","provincia":"","py_initial":"","quan_pin":"","sex":0,"signature":"","small_head":"","status":-24,"stranger":"","user_name":""}
01:45:53 INFO PadchatRpc WXSearchContact wxid: wxid_o9yzflim2f0n12 cannot be searched
01:45:53 SILL PuppetPadchat contactRawPayloadParser({user_name=""})
01:45:53 ERR Contact ready() this.puppet.contactPayload(Contact) exception: cannot get user_name from raw payload: {"big_head":"","city":"","country":"","message":"\n�\u0002<e>\n<ShowType>1</ShowType>\n<Content><![CDATA[找不到相关帐号或内容]]></Content>\n<Url><![CDATA[]]></Url>\n<DispSec>30</DispSec>\n<Title><![CDATA[]]></Title>\n<Action>2</Action>\n<DelayConnSec>0</DelayConnSec>\n<Countdown>0</Countdown>\n<Ok><![CDATA[]]></Ok>\n<Cancel><![CDATA[]]></Cancel>\n</e>\n","nick_name":"","provincia":"","py_initial":"","quan_pin":"","sex":0,"signature":"","small_head":"","status":-24,"stranger":"","user_name":""}
01:45:53 SILL PadchatRpc WXSearchContact result: {"big_head":"","city":"","country":"","message":"\n�\u0002<e>\n<ShowType>1</ShowType>\n<Content><![CDATA[操作过于频繁,请稍后再试]]></Content>\n<Url><![CDATA[]]></Url>\n<DispSec>30</DispSec>\n<Title><![CDATA[]]></Title>\n<Action>2</Action>\n<DelayConnSec>0</DelayConnSec>\n<Countdown>0</Countdown>\n<Ok><![CDATA[]]></Ok>\n<Cancel><![CDATA[]]></Cancel>\n</e>\n","nick_name":"","provincia":"","py_initial":"","quan_pin":"","sex":0,"signature":"","small_head":"","status":-24,"stranger":"","user_name":""}
01:45:53 INFO PadchatRpc WXSearchContact wxid: yyf2010555 cannot be searched
01:45:53 SILL PuppetPadchat contactRawPayloadParser({user_name=""})
01:45:53 ERR Contact ready() this.puppet.contactPayload(Contact) exception: cannot get user_name from raw payload: {"big_head":"","city":"","country":"","message":"\n�\u0002<e>\n<ShowType>1</ShowType>\n<Content><![CDATA[操作过于频繁,请稍后再试]]></Content>\n<Url><![CDATA[]]></Url>\n<DispSec>30</DispSec>\n<Title><![CDATA[]]></Title>\n<Action>2</Action>\n<DelayConnSec>0</DelayConnSec>\n<Countdown>0</Countdown>\n<Ok><![CDATA[]]></Ok>\n<Cancel><![CDATA[]]></Cancel>\n</e>\n","nick_name":"","provincia":"","py_initial":"","quan_pin":"","sex":0,"signature":"","small_head":"","status":-24,"stranger":"","user_name":""}
01:45:53 SILL PadchatRpc WXSearchContact result: {"big_head":"","city":"","country":"","message":"\n�\u0002<e>\n<ShowType>1</ShowType>\n<Content><![CDATA[操作过于频繁,请稍后再试]]></Content>\n<Url><![CDATA[]]></Url>\n<DispSec>30</DispSec>\n<Title><![CDATA[]]></Title>\n<Action>2</Action>\n<DelayConnSec>0</DelayConnSec>\n<Countdown>0</Countdown>\n<Ok><![CDATA[]]></Ok>\n<Cancel><![CDATA[]]></Cancel>\n</e>\n","nick_name":"","provincia":"","py_initial":"","quan_pin":"","sex":0,"signature":"","small_head":"","status":-24,"stranger":"","user_name":""}
01:45:53 INFO PadchatRpc WXSearchContact wxid: wxid_hjjqix6dojdr12 cannot be searched
01:45:53 SILL PuppetPadchat contactRawPayloadParser({user_name=""})
01:45:53 ERR Contact ready() this.puppet.contactPayload(Contact) exception: cannot get user_name from raw payload: {"big_head":"","city":"","country":"","message":"\n�\u0002<e>\n<ShowType>1</ShowType>\n<Content><![CDATA[操作过于频繁,请稍后再试]]></Content>\n<Url><![CDATA[]]></Url>\n<DispSec>30</DispSec>\n<Title><![CDATA[]]></Title>\n<Action>2</Action>\n<DelayConnSec>0</DelayConnSec>\n<Countdown>0</Countdown>\n<Ok><![CDATA[]]></Ok>\n<Cancel><![CDATA[]]></Cancel>\n</e>\n","nick_name":"","provincia":"","py_initial":"","quan_pin":"","sex":0,"signature":"","small_head":"","status":-24,"stranger":"","user_name":""}
01:45:53 SILL PadchatRpc WXSearchContact result: {"big_head":"","city":"","country":"","message":"\n�\u0002<e>\n<ShowType>1</ShowType>\n<Content><![CDATA[操作过于频繁,请稍后再试]]></Content>\n<Url><![CDATA[]]></Url>\n<DispSec>30</DispSec>\n<Title><![CDATA[]]></Title>\n<Action>2</Action>\n<DelayConnSec>0</DelayConnSec>\n<Countdown>0</Countdown>\n<Ok><![CDATA[]]></Ok>\n<Cancel><![CDATA[]]></Cancel>\n</e>\n","nick_name":"","provincia":"","py_initial":"","quan_pin":"","sex":0,"signature":"","small_head":"","status":-24,"stranger":"","user_name":""}
01:45:53 INFO PadchatRpc WXSearchContact wxid: wxid_v6hwv4tc5na921 cannot be searched
01:45:53 SILL PuppetPadchat contactRawPayloadParser({user_name=""}) Maybe this is because So maybe we shouldn't change |
Thanks @lijiarui for your investigation. You make it easy to answer @zixia 's comment. We need to load the data from roomMember instead of contact. Then I got another question. I think @zixia could answer this well. I think it's better to keep align with the original design so we don't break anyone. What's the original design for room member? Are these information also supposed to be stored in |
In Wechaty, the original design for room member is to get the room related information for the contact, for example, the room alias. So that information is all stored in the Contact, exception the Please see the related commits and I had made today, and feel free to let me know if you have any suggestions/questions, and any further improvements are welcome. |
After reading code carefully, I find that there are two places that writes the contact information to cache. Code in Besides, seems like the If this makes sense to you @zixia , I will submit a PR later. Let me know what do you think. |
Thank you for reading code carefully. I believe we should create a new issue because the discussion right now is not related to the current title of And also please notice that I had moved all the code base related to the About the PR: Please feel free to submit PR at /~https://github.com/lijiarui/wechaty-puppet-padchat instead here, because all the code related to the padchat had been frozen in this repository to prevent source code inconsistent. Make sure you had tested it locally, and submit with unit tests will be recommend. |
Cool, I will close this issue. |
contactRawPayload
inpadchat-manager.ts
is usingWXGetContactPayload
method to get the contact. Sometimes, thecontactId
passed tocontactRawPayload
might not be the friend of the user.Per my investigation, when
message.ts
callready
method, it will also callready
method on the from and toContact
. If this message is from a room, the from might not be the friend of the bot, thenready
in Contact will try to load the data for the contact, but since the contact is not a friend, withGetContactPayload
, there will be no results for it. After that, this payload will be passed tocontactRawPayloadParser
, and the parser can not read out theuser_name
, thus cause breakage of the bot.Do you think we should change the method in
contactRawPayload
method?The text was updated successfully, but these errors were encountered: