Skip to content

Wechat帐号界面语言设为中文环境下:wechaty的room-join room-leave room-topic 事件无法触发 #52

@lijiarui

Description

@lijiarui

room-join
room-leave
room-topic
以上三个event,无法成功触发

代码如下:

import {
  Wechaty
  , log
} from '../'

const bot = Wechaty.instance({ profile: 'TestFun' })

bot
.on('login'   , user => log.info('Bot', `${user.name()} logined`))
.on('logout'  , user => log.info('Bot', `${user.name()} logouted`))
.on('error'   , e => log.info('Bot', 'error: %s', e))
.on('scan', (url, code) => {
  if (!/201|200/.test(String(code))){
    let loginUrl = url.replace(/\/qrcode\//, '/l/')
    require('qrcode-terminal').generate(loginUrl)
  }
  console.log(`${url}\n[${code}] Scan QR Code in above url to login: `)
})

.on('room-join', (room, invitee, inviter) => {
  console.log("room-join@@@@@@@@@@@@@")
})

.on('room-leave', (room, leaver) => {
  console.log("room-leave!!!!!!!!")
})

.on('room-topic', (room, topic, oldTopic, changer) => {
  try {
    console.log('room-topic##############')
  } catch (e) {
    log.error('Bot', 'room-topic event exception: %s', e.stack)
  }
})

.on('message', m => {
  m.ready()
  .then(msg => {

  const room    = msg.room()
  const sender  = msg.from()

  console.log((room ? '[' + room.topic() + ']' : '')
              + '<' + sender.name() + '>'
              + ':' + msg.toStringDigest()
  )

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

bot.init()
.catch(e => {
  log.error('Bot', 'init() fail: %s', e)
  bot.quit()
  process.exit(-1)
})

当群中拉入成员、删除成员、修改群名,理应打印出:

room-join@@@@@@@@@@@@@
room-leave!!!!!!!!
room-topic##############

实际上并没有打印出以上内容,仅仅作为消息形式,日志输出如下:(加入好友的情况)

SILL Message ready()
SILL Contact constructor(@@dfd07c3e0246851cc2084e1ffc9983d2d5d833331b6b2e1c64c41b206035b176)
SILL Room constructor(@@dfd07c3e0246851cc2084e1ffc9983d2d5d833331b6b2e1c64c41b206035b176)
SILL Contact ready()
SILL Contact get contact via PuppetWeb
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL PuppetWebBrowser dead()
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL PuppetWebBrowser dead()
SILL Contact contactGetter(@@dfd07c3e0246851cc2084e1ffc9983d2d5d833331b6b2e1c64c41b206035b176) resolved
SILL Contact ready()
SILL Room ready()
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL PuppetWebBrowser dead()
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL PuppetWebBrowser dead()
SILL Room contactGetter(@@dfd07c3e0246851cc2084e1ffc9983d2d5d833331b6b2e1c64c41b206035b176) resolved
SILL Contact constructor(@7e50d293942e6e283a3143c3dd42fb05afc9647b2c2d4ce68dab17a3fe13810d)
SILL Contact ready()
SILL Contact ready()
SILL Contact get contact via PuppetWeb
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL PuppetWebBrowser dead()
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL PuppetWebBrowser dead()
SILL Contact contactGetter(@7e50d293942e6e283a3143c3dd42fb05afc9647b2c2d4ce68dab17a3fe13810d) resolved
VERB PuppetWebFirer fireRoomJoin(你邀请"李佳芮"加入了群聊)
VERB PuppetWebFirer checkRoomJoin()
VERB PuppetWebFirer fireRoomLeave(你邀请"李佳芮"加入了群聊)
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
[ding哦哦]<ding哦哦>:{SYS}你邀请"李佳芮"加入了群聊
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
[ding哦哦]<wuli舞哩>:{TEXT}wuli舞哩:欢迎 @李佳芮 入群

在移除好友时:

SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
VERB PuppetWebFirer fireRoomJoin(你将"李佳芮"移出了群聊)
VERB PuppetWebFirer checkRoomJoin()
VERB PuppetWebFirer fireRoomLeave(你将"李佳芮"移出了群聊)
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
[ding哦哦]<ding哦哦>:{SYS}你将"李佳芮"移出了群聊

在修改群名称时:

SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
VERB PuppetWebFirer fireRoomJoin("李佳芮"修改群名为“ding”)
VERB PuppetWebFirer checkRoomJoin()
VERB PuppetWebFirer fireRoomLeave("李佳芮"修改群名为“ding”)
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Room ready()
[ding哦哦]<ding哦哦>:{SYS}"李佳芮"修改群名为“ding”

为什么会没有触发到
.on('room-join', (room, invitee, inviter)
.on('room-leave', (room, leaver)
.on('room-topic', (room, topic, oldTopic, changer)
里面的内容呢?

谢谢!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions