Skip to content

Function message.to(): Contact|Room bug #88

@lijiarui

Description

@lijiarui

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

wechaty@0.5.9 doctor /wechaty
ts-node bin/doctor

Wechaty Doctor

  1. Wechaty version: 0.5.9
  2. Linux x64 version 3.16.0-4-amd64 memory 283/1000 MB
  3. Docker: true
  4. Node version: v7.1.0

Code

I' trying use message.to() method, the full code as follows

import { Wechaty} from 'wechaty'

const bot = Wechaty.instance()
bot
.on('scan' ,(url,code)=>{console.log(url)})

.on('login',username=>{console.log(username.name())})

.on('message', m=> {
  const content = m.content()
  const to = m.to()
  const from = m.from()
  const room = m.room()
  if(room)
    console.log(`MessageReciver:${to}  content:${content} form:${from} in room: ${room}`) 
    else
    console.log(`MessageReciver:${to} ; content:${content};form:${from}`)
})
.init()

Expected behavior

When someone(not the bot itself) says "hello" in the room, m.to() should return room, but now, m.room() return contact

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

I login in with username '李佳芮' , then create a room called 'testmsg'.

When the bot itself speaking in the room 'testmsg', m.to() return the room 'testmsg' as expected.
Log as follows:(console.log(MessageReciver:${to} content:${content} form:${from} in room: ${room}) )

SILL Message constructor() SN:4
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
MessageReciver:@@f02e19fceda71e02614ffe7820e6599d656cf4cb24695364a88d16d943666a1b content:test1 form:李佳芮 in room: @@f02e19fceda71e02614ffe7820e6599d656cf4cb24695364a88d16d943666a1b

When other people speaking in room 'testmsg' ,m.to() return to the contact which username is '李佳芮'.(I think it should return room)
Log as follows:(console.log(MessageReciver:${to} content:${content} form:${from} in room: ${room}) )

SILL Message constructor() SN:5
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
MessageReciver:李佳芮 content:test2 form:邀群助手 in room: @@f02e19fceda71e02614ffe7820e6599d656cf4cb24695364a88d16d943666a1b

While, I think this message 's receiver is the room 'testmsg', so it should return room 'testmsg' , not the bot.

I wonder know is it a bug or you intented this return value? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions