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

get room owner on event 'room-join','room-topic' #105

Merged
merged 4 commits into from
Nov 26, 2016
Merged

Conversation

JasLin
Copy link
Contributor

@JasLin JasLin commented Nov 25, 2016

issue 1:

wxwebApp had hide uin of room members from some routing. so we can't get owner by using uin anymore:

memberList = memberList.filter(m => m.get('uin') === ownerUin)
     if (memberList.length > 0) {
       return memberList[0]
     } else {
       return null
     }

but on 'room-join' and 'room-topic' event ,we got a ``ChatRoomOwner``` property from rawObj, it can be used to load owner..

rawObj:
   { Alias: '',
     AppAccountFlag: 0,
     AttrStatus: 0,
     ChatRoomId: 0,
     ChatRoomOwner: '@b261a88d4de1479cdf735c851fe22afe',
     City: '',
     ContactFlag: 2,
     DisplayName: '',
     EncryChatRoomId: '@dfee772e7d01ad0cfcdc5e2e8c81e558',
     HeadImgUpdateFlag: 1,
     HeadImgUrl: '/cgi-bin/mmwebwx-bin/webwxgetheadimg?seq=0&username=@@72317905edc07327e00aa61f690de1ea2a98117aca6ff32ddfe4eb0&skey=@crypt_9d729d2b_71e57bdd5f75
90fee74da393476f8160',
     HideInputBarFlag: 0,
     KeyWord: '',
     MMFromBatchGet: true,
     MMFromBatchget: true,
     MMInChatroom: true,
...

@JasLin
Copy link
Contributor Author

JasLin commented Nov 25, 2016

i hate whitespace...

@JasLin
Copy link
Contributor Author

JasLin commented Nov 25, 2016

@zixia can not found those new modules?

https://travis-ci.org/wechaty/wechaty/jobs/178773741#L362

example/voice-to-text-bot.ts(13,31): error TS2307: Cannot find module 'request'.
example/voice-to-text-bot.ts(14,31): error TS2307: Cannot find module 'fluent-ffmpeg'.

@JasLin
Copy link
Contributor Author

JasLin commented Nov 25, 2016

issues 2: throw new Error('no user')

when i trying to use https://app.wechaty.io.

reproduce

  1. start robot
  2. and then opening wechaty.io
  3. login
  4. robot got error
/home/jas/projects/learning/wechat/wechaty-ts/src/wechaty.ts:127
      throw new Error('no user')
            ^
Error: no user
    at Wechaty.user (/home/jas/projects/learning/wechat/wechaty-ts/src/wechaty.ts:127:13)
    at WebSocket.ws.on.e (/home/jas/projects/learning/wechat/wechaty-ts/src/io.ts:221:45)
    at emitTwo (events.js:106:13)
    at WebSocket.emit (events.js:191:7)
    at Receiver.ontext (/home/jas/projects/learning/wechat/wechaty-ts/node_modules/ws/lib/WebSocket.js:841:10)
    at /home/jas/projects/learning/wechat/wechaty-ts/node_modules/ws/lib/Receiver.js:536:18
    at /home/jas/projects/learning/wechat/wechaty-ts/node_modules/ws/lib/Receiver.js:368:7
    at /home/jas/projects/learning/wechat/wechaty-ts/node_modules/ws/lib/PerMessageDeflate.js:249:5
    at afterWrite (_stream_writable.js:387:3)
    at onwrite (_stream_writable.js:378:7)

i trace the code . when login in web , it will send a ws event 'update' to robot. and it will call wechaty.user() , at the same time ,because user haven't login ,the wechaty.user() will throw errors.

i change it to wechaty.puppet.user directly . then everything is ok.

c222fa1

@huan
Copy link
Member

huan commented Nov 26, 2016

Great hack for the ChatRoomOwner property, thanks!

I'll check the new module requirement problem in the package.json, it's my bad.

BTW: app.wechaty.io is using a very early stage WebSocket protocol to communicate with Wechaty Runtime(as I named it: a Chatie), so there will be expected others' problem as well, so please be careful when you are using it.

@huan huan merged commit 09a7aae into wechaty:master Nov 26, 2016
@huan
Copy link
Member

huan commented Nov 26, 2016

CI failed becasue I forgot to run npm install @types/request @types/fluent-ffmpeg --save-dev. fixed.

huan added a commit that referenced this pull request Nov 26, 2016
@huan huan moved this from Hacking 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
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants