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

Room.find() can find the room when the bot is removed from the room #254

Closed
lijiarui opened this issue Feb 15, 2017 · 2 comments
Closed

Comments

@lijiarui
Copy link
Member

lijiarui commented Feb 15, 2017

Run npm run doctor or wechaty run doctor(for docker user), paste output here

> wechaty@0.7.32 doctor /Users/lijiarui/Documents/git/wechaty
> npm run check-node-version && ts-node bin/doctor


> wechaty@0.7.32 check-node-version /Users/lijiarui/Documents/git/wechaty
> check-node-version --node ">= 6.9"

node: v7.0.0
npm: v4.0.5

  #### Wechaty Doctor

  1. Wechaty version: #git[7faecd6 0.7.32]
  2. Darwin x64 version 14.5.0 memory 831/16384 MB
  3. Docker: false
  4. Node version: v7.0.0
  5. Tcp IPC TEST: PASS

Expected behavior

When the bot is removed from the room, function Room.find() shouldn't find the room.

Actual behavior

When the bot is removed from the room, function Room.find() shouldn't find the room.

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

1. Trying the following code

.on('login'	  , async user => {
  log.info('Bot', `${user.name()} logined`)
  bot.say('Wechaty login')
  setTimeout (async function(){ 
    await testRoom()
  }, 10 * 1000)

  setTimeout (async function(){ 
    await testRoom()
  }, 200 * 1000)
})

async function testRoom() {
  const room = await Room.find({topic:'呵呵呵呵'})
  if (room) {
    room.refresh()
    console.log('========find the room ===========')
    console.log(room)
  } else {
    console.log('========cannot find the room==========')
  }
}

When running the first function await testRoom(), the bot in the room, all works well.

Then I removed the bot from the room.

When running the second function await testRoom(), the bot isn't in the room, and I check the web weixin, the bot isn't in the room, but it still can find the room, all the data are same as the first one.

2. Relogin with the existed session using the code above

It still can find the room, but the memberList is null.

log as follows:

Room {
  domain: null,
  _events: {},
  _eventsCount: 0,
  _maxListeners: undefined,
  id: '@@68830d9c45cfcc6dce9830e1962895879d61d511d27a209ebfd9949dd5ab1ddd',
  rawObj:
   { Alias: '',
     AttrStatus: 0,
     ChatRoomOwner: '@f3be6437726924c11b2d4ac8de32771f9241b01b1bd0f56cdc0c7946b3a550dc',
     City: '',
     ContactFlag: 2,
     ContactType: 0,
     HeadImgUpdateFlag: 1,
     HeadImgUrl: '/cgi-bin/mmwebwx-bin/webwxgetheadimg?seq=0&username=@@68830d9c45cfcc6dce9830e1962895879d61d511d27a209ebfd9949dd5ab1ddd&skey=@crypt_74655fd7_25ff145d207e4ce54116970ee5609818',
     HideInputBarFlag: 0,
     KeyWord: '',
     MMOrderSymbol: '~',
     MemberCount: 0,
     MemberList: [],
     NickName: '呵呵呵呵',
     PYInitial: '',
     PYQuanPin: '',
     Province: '',
     RemarkName: '',
     RemarkPYInitial: '',
     RemarkPYQuanPin: '',
     Sex: 0,
     Signature: '',
     SnsFlag: 0,
     Statues: 0,
     UserName: '@@68830d9c45cfcc6dce9830e1962895879d61d511d27a209ebfd9949dd5ab1ddd',
     VerifyFlag: 0,
     stranger: true },
  obj: null }
WARN Room ready() has obj.id but memberList empty in room 呵呵呵呵. reloading
@huan
Copy link
Member

huan commented Aug 18, 2017

It's because the WebWechat has cached that. I guess you can also find that room in your web browser?

@huan
Copy link
Member

huan commented Aug 18, 2018

After the bot was removed from the room, Wechaty (or puppet) should call puppet.roomPayloadDirty(roomId) to clean the cache. (after wechaty@0.18)

@huan huan closed this as completed in f94a4c3 Aug 19, 2018
huan added a commit that referenced this issue Aug 19, 2018
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

2 participants