Skip to content

Commit

Permalink
add room join demo #12
Browse files Browse the repository at this point in the history
  • Loading branch information
lijiarui committed Dec 15, 2019
1 parent cf81995 commit 01741b5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/handlers/on-message.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import {
log,
Message,
Room,
Wechaty,
} from 'wechaty'

export default async function onMessage (
this : Wechaty,
message : Message,
): Promise<void> {
const text = message.text()
const contact = message.from()
if (!contact) {
return
}
if (text === 'oss') {

// To Be Fix: Change "OSS Bot ChatOps" Group Name to actual group name
const room = await Room.find({ topic: 'OSS Bot ChatOps' })
if (room) {
await room.add(contact)

// To Be Fix: Change a formal welcome message
await room.say('Welcome to join OSS Bot ChatOps Group', contact)
}
}
log.info('on-message', 'onMessage(%s)', message)
}

0 comments on commit 01741b5

Please sign in to comment.