Skip to content

Commit

Permalink
feat(lark): add more api, correct function name (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikoTan authored Dec 23, 2023
1 parent bf6bdea commit ae058ac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion adapters/lark/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class LarkBot<C extends Context = Context> extends Bot<C, LarkBot.Config>
}

async getUser(userId: string, guildId?: string) {
const data = await this.internal.getUserInfo(userId)
const data = await this.internal.getContactUser(userId)
return Utils.decodeUser(data.data)
}

Expand Down
17 changes: 17 additions & 0 deletions adapters/lark/src/types/message/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,17 @@ declare module '../internal' {
getMessage(message_id: string): Promise<BaseResponse & { data: Message }>
/** @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/delete */
deleteMessage(message_id: string): Promise<BaseResponse>
/** @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/forward */
forwardMessage(
message_id: string,
receive_id_type: Lark.ReceiveIdType,
data: { receive_id: string },
): Promise<BaseResponse & { data: Message }>
/** @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/merge_forward */
mergeForwardMessage(
receive_id_type: Lark.ReceiveIdType,
data: { receive_id: string; message_id_list: string[] },
): Promise<BaseResponse & { data: { message: Message; invalid_message_id_list: string[] }}>
/** @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/read_users */
getMessageReadUsers(message_id: string, params: Pagination<{ user_id_type: Lark.UserIdType }>): Promise<BaseResponse & { data: Paginated<ReadUser> }>
/** @see https://open.larksuite.com/document/server-docs/im-v1/message/list */
Expand All @@ -230,4 +241,10 @@ Internal.define({
'/im/v1/messages/{message_id}/read_users': {
GET: 'getMessageReadUsers',
},
'/im/v1/messages/{message_id}/forward?receive_id_type={receive_id_type}': {
POST: 'forwardMessage',
},
'/im/v1/messages/merge_forward?receive_id_type={receive_id_type}': {
POST: 'mergeForwardMessage',
},
})
4 changes: 2 additions & 2 deletions adapters/lark/src/types/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ export interface GuildMember {
declare module './internal' {
export interface Internal {
/** @see https://open.larksuite.com/document/server-docs/contact-v3/user/get */
getUserInfo(user_id: string, user_id_type?: Lark.UserIdType, department_id_type?: Lark.DepartmentIdType): Promise<BaseResponse & { data: Lark.User }>
getContactUser(user_id: string, user_id_type?: Lark.UserIdType, department_id_type?: Lark.DepartmentIdType): Promise<BaseResponse & { data: Lark.User }>
}
}

Internal.define({
'contact/v3/users/{user_id}': {
GET: 'getUserInfo',
GET: 'getContactUser',
},
})

0 comments on commit ae058ac

Please sign in to comment.