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

Find chatops room by id instead of the topic. #21

Merged
merged 4 commits into from
Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oss-bot",
"version": "0.0.24",
"version": "0.0.25",
"description": "Apache OSS Bot",
"main": "index.js",
"engines": {
Expand Down
4 changes: 1 addition & 3 deletions src/chatops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import {

import {
log,
CHATOPS_ROOM_ID,
} from './config'

// const CHATOPS_ROOM_TOPIC = 'OSS Bot ChatOps'
const CHATOPS_ROOM_ID = '18995691396@chatroom'

let room: Room

export async function chatops (
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export const VERSION = pkg.version
* Env Vars
*/
export const PORT = process.env.PORT || 8788

export const CHATOPS_ROOM_ID = '18995691396@chatroom'
9 changes: 7 additions & 2 deletions src/handlers/on-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import {
Wechaty,
} from 'wechaty'

import {
CHATOPS_ROOM_ID,
} from '../config'

export default async function onMessage (
this : Wechaty,
message : Message,
Expand All @@ -13,11 +17,12 @@ export default async function onMessage (
if (!contact) {
return
}
if (text === 'oss') {
if (text.toLowerCase() === 'oss') {

// To Be Fix: Change "OSS Bot ChatOps" Group Name to actual group name
log.info('on-message', 'Begin to find the OSS Bot ChatOps room')
const room = await this.Room.find({ topic: 'OSS Bot ChatOps' })
const room = this.Room.load(CHATOPS_ROOM_ID)

if (room) {
await room.add(contact)

Expand Down