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

it seems RECALLED: 10002 message dose't trigger on('message') event #8

Closed
JasLin opened this issue Jun 23, 2016 · 9 comments · Fixed by #744
Closed

it seems RECALLED: 10002 message dose't trigger on('message') event #8

JasLin opened this issue Jun 23, 2016 · 9 comments · Fixed by #744

Comments

@JasLin
Copy link
Contributor

JasLin commented Jun 23, 2016

i tested the ding-dong-bot and recalled some message , it dose not trigger the event.

@JasLin JasLin changed the title it seems RECALLED: 10002 message dose't on('message') event it seems RECALLED: 10002 message dose't trigger on('message') event Jun 23, 2016
@huan
Copy link
Member

huan commented Jun 27, 2016

Hi JasLin,

when you run ding-dong-bot, there should be a scan event first, with the login qrcode url that you need to scan to login.

the message event will be emitted after login, at the time when you receive a new message.

@JasLin
Copy link
Contributor Author

JasLin commented Jun 28, 2016

@zixia thanks for your reply , actually , i have used wechaty in my programs. i write a robot to serve some business, and everything is ok , but the when i recalled message from my wechat in mobile, it never trigger the message event . the test code is simple:

...
.on('message', m => {
  m.ready()
  .then(msg => {
    log.info('Bot', 'recv: %s', msg.toStringEx())
    logToFile(JSON.stringify(msg.rawObj))
    // test recalled message
    if(msg.type() === Message.Type.RECALLED){
        console.log('recalled a message')
        msg.dumpRaw()
    }
    ...

  })
  .catch(e => log.error('Bot', 'ready: %s' , e))
})

there is no message received after recalled some messages from mobile.

BTW: thanks for wechaty again, it may be the best wecaht sdk i have seen in github. i had move my code from python to javascript after compare with wechaty and some python wechat sdk .

@hexsum
Copy link

hexsum commented Jun 28, 2016

it may be the best wecaht sdk i have seen in github

相当高的评价,我也赞一个

@huan huan added the bug label Jun 28, 2016
@huan huan self-assigned this Jun 28, 2016
@huan
Copy link
Member

huan commented Jun 28, 2016

@JasLin confirmed.

It seems the message of type RECALLED is not triggered in the current hook process.

It must has other hook point of this type of message, will figure it out when I have time.

also, thanks for your favorable comment! I'd like to write it to README :) and thanks @sjdy521, too!

@huan
Copy link
Member

huan commented Nov 12, 2016

@JasLin do u have any idea of how to fix this issue? i'm going to review it next week.

@JasLin
Copy link
Contributor Author

JasLin commented Nov 13, 2016

@zixia i haven't dig into this issue yet, this issue not so harmfull ,or i will going to see this next week too.

@huan
Copy link
Member

huan commented Nov 14, 2016

About the RECALLED Message behavior of webwxApp:

Problem

  1. RECALLED Message will not be processed like other messages:

    https://github.com/wechaty/webwx-app-tracker/blob/06ba28a762e4f13d1710962577afb53017d2190f/formatted/webwxApp.js#L2007

  2. It do return instead of call addChatMessage():

    https://github.com/wechaty/webwx-app-tracker/blob/06ba28a762e4f13d1710962577afb53017d2190f/formatted/webwxApp.js#L2034

  3. So there will no message:add:success broadcast event fired for any RECALL Message:

    https://github.com/wechaty/webwx-app-tracker/blob/06ba28a762e4f13d1710962577afb53017d2190f/formatted/webwxApp.js#L1930

  4. At last Wechaty will never get it.

Solution

We need to add addChatMessage() call to process a RECALLED message.

  1. wrap _recalledMsgProcess()

    https://github.com/wechaty/webwx-app-tracker/blob/06ba28a762e4f13d1710962577afb53017d2190f/formatted/webwxApp.js#L2007

  2. wrap messageProcess()

    https://github.com/wechaty/webwx-app-tracker/blob/06ba28a762e4f13d1710962577afb53017d2190f/formatted/webwxApp.js#L1971

  3. any other good idea/suggestion/brainstorming?

TBD

See Also

  1. Prevent Recalling Messages (Prototype): arrowrowe/electronic-wechat@3126eee

@zhaozhiming
Copy link

Do the solutions above have not help?

@huan
Copy link
Member

huan commented Aug 26, 2017

Close this issue because the PR will be merged soon.

@huan huan closed this as completed Aug 26, 2017
huan pushed a commit that referenced this issue Sep 3, 2017
* fix(wechaty-bro): resolved emit RECALLED type msg

fix #8

* add(message): add getRevokeId(), Return the recalled message id

* fix(wechaty-bro): modify `hookProcess` to `hookRecalledProcess`

modify `_this` to `chatFactory`

* fix(wechaty-bro): Remain a blank message after repairing the recall message

* fix(wechaty-bro): Unify the data returned by the RECALLED type message

remove Message.getRevokeId function
@huan huan moved this from Opportunity to Final Boss in Hacking Opportunity Apr 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants