Skip to content

Commit

Permalink
fix bug #26
Browse files Browse the repository at this point in the history
  • Loading branch information
padlocal committed Jan 4, 2021
1 parent 69fa1c1 commit 1a33ae0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/padlocal/schema-mapper/index.ts
Expand Up @@ -4,6 +4,7 @@ import {
ContactType,
MessagePayload,
MessageType,
Puppet,
RoomMemberPayload,
RoomPayload,
} from "wechaty-puppet";
Expand All @@ -15,7 +16,7 @@ import { log } from "wechaty";

const PRE = "[SchemaMapper]";

export async function padLocalMessageToWechaty(message: Message.AsObject): Promise<MessagePayload> {
export async function padLocalMessageToWechaty(puppet: Puppet, message: Message.AsObject): Promise<MessagePayload> {
const wechatMessageType = message.type as WechatMessageType;
const type = convertMessageType(wechatMessageType);

Expand Down Expand Up @@ -65,7 +66,12 @@ export async function padLocalMessageToWechaty(message: Message.AsObject): Promi

// set mention list
if (roomId) {
mentionIdList = message.atList;
if (message.atList.length === 1 && message.atList[0] === "announcement@all") {
const roomPayload = await puppet.roomPayload(roomId);
mentionIdList = roomPayload.memberIdList;
} else {
mentionIdList = message.atList;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/puppet-padlocal.ts
Expand Up @@ -1117,7 +1117,7 @@ class PuppetPadlocal extends Puppet {
}

public async messageRawPayloadParser(payload: Message.AsObject): Promise<MessagePayload> {
return padLocalMessageToWechaty(payload);
return padLocalMessageToWechaty(this, payload);
}

public async messageRawPayload(id: string): Promise<Message.AsObject> {
Expand Down

0 comments on commit 1a33ae0

Please sign in to comment.