Skip to main content

Listen to events

tip

The Wechaty Events are all the same acrossing Polyglot Wechaty programs!

Basic Events#

scan Event: QR code#

TODO: introducing scan event

import { ScanStatus } from 'wechaty'
async function onScan (  qrcode: undefined | string,  status: ScanStatus,) {  console.info('Scan QR Code to login, status:', status, ScanStatus[status])  console.info('https://wechaty.js.org/qrcode/' + encodeURIComponent(qrcode))}
bot.on('scan', onScan)await bot.start()

login Event: bot contact#

TODO: introducing login event

import { Contact } from 'wechaty'
function onLogin (bot: Contact) {  console.info('Bot logged in:', bot)}
bot.on('login', onLogin)await bot.start()

logout Event#

TODO: introducing logout event

// TODO: Pull Request is welcome!

message Event#

TODO: introducing message event

import { Message } from 'wechaty'
function onMessage (message: Message) {  console.info('New message:', message)}
bot.on('message', onMessage)await bot.start()

friendship Event: friend requests#

TODO: introducing friendship event

// TODO: Pull Request is welcome!

Room Events#

room-topic Event: messages#

TODO: introducing room-topic event

// TODO: Pull Request is welcome!

room-invite Event: messages#

TODO: introducing room-invite event

// TODO: Pull Request is welcome!

room-join Event: messages#

TODO: introducing room-join event

// TODO: Pull Request is welcome!

room-leave Event: messages#

TODO: introducing room-leave event

// TODO: Pull Request is welcome!

System events#

ready Event#

TODO: introducing ready event

// TODO: Pull Request is welcome!

heartbeat Event: messages#

TODO: introducing heartbeat event

// TODO: Pull Request is welcome!

error Event#

TODO: introducing error event

// TODO: Pull Request is welcome!