From c8b2f42db22c4957883d694ff106360721ce3cc1 Mon Sep 17 00:00:00 2001 From: David Zhang Date: Wed, 27 Dec 2023 14:10:47 +0800 Subject: [PATCH] chore(im): change api name to make it consistent --- README.md | 4 ++-- README_zhCN.md | 4 ++-- api_message.go | 24 ++++++++++++------------ api_message_test.go | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 526e69d..305ed3f 100644 --- a/README.md +++ b/README.md @@ -128,8 +128,8 @@ For Chat Bot, we can send simple messages with the following method: - `PostImage` - `PostShareChatCard` - `ReplyMessage` -- `ReactionMessage` -- `DeleteReactionMessage` +- `AddReaction` +- `DeleteReaction` Basic message examples: [examples/basic-message](https://github.com/go-lark/examples/tree/main/basic-message) diff --git a/README_zhCN.md b/README_zhCN.md index cee3216..9d1aa14 100644 --- a/README_zhCN.md +++ b/README_zhCN.md @@ -123,8 +123,8 @@ resp, err := bot.GetTenantAccessTokenInternal(true) - `PostImage` - `PostShareChatCard` - `ReplyMessage` -- `ReactionMessage` -- `DeleteReactionMessage` +- `AddReaction` +- `DeleteReaction` 参考实例:[基本消息](https://github.com/go-lark/examples/tree/main/basic-message)。 diff --git a/api_message.go b/api_message.go index 275857d..e27ba2f 100644 --- a/api_message.go +++ b/api_message.go @@ -244,7 +244,7 @@ func (bot Bot) PostShareUser(openID string, userID *OptionalUserID) (*PostMessag return bot.PostMessage(om) } -// PostMessage posts message +// PostMessage posts a message func (bot Bot) PostMessage(om OutcomingMessage) (*PostMessageResponse, error) { req, err := BuildMessage(om) if err != nil { @@ -260,7 +260,7 @@ func (bot Bot) PostMessage(om OutcomingMessage) (*PostMessageResponse, error) { return &respData, err } -// ReplyMessage replies messages +// ReplyMessage replies a message func (bot Bot) ReplyMessage(om OutcomingMessage) (*PostMessageResponse, error) { req, err := BuildMessage(om) if err != nil { @@ -274,26 +274,26 @@ func (bot Bot) ReplyMessage(om OutcomingMessage) (*PostMessageResponse, error) { return &respData, err } -// ReactionMessage reactions messages -func (bot Bot) ReactionMessage(messageID string, emojiType EmojiType) (*ReactionResponse, error) { +// AddReaction adds reaction to a message +func (bot Bot) AddReaction(messageID string, emojiType EmojiType) (*ReactionResponse, error) { req := map[string]interface{}{ "reaction_type": map[string]interface{}{ "emoji_type": emojiType, }, } var respData ReactionResponse - err := bot.PostAPIRequest("ReactionMessage", fmt.Sprintf(reactionsMessageURL, messageID), true, req, &respData) + err := bot.PostAPIRequest("AddReaction", fmt.Sprintf(reactionsMessageURL, messageID), true, req, &respData) return &respData, err } -// DeleteReactionMessage delete reactions messages -func (bot Bot) DeleteReactionMessage(messageID string, reactionID string) (*ReactionResponse, error) { +// DeleteReaction deletes reaction of a message +func (bot Bot) DeleteReaction(messageID string, reactionID string) (*ReactionResponse, error) { var respData ReactionResponse - err := bot.DeleteAPIRequest("DeleteReactionMessage", fmt.Sprintf(deleteReactionsMessageURL, messageID, reactionID), true, nil, &respData) + err := bot.DeleteAPIRequest("DeleteReaction", fmt.Sprintf(deleteReactionsMessageURL, messageID, reactionID), true, nil, &respData) return &respData, err } -// UpdateMessage update message card +// UpdateMessage updates a message func (bot Bot) UpdateMessage(messageID string, om OutcomingMessage) (*UpdateMessageResponse, error) { if om.MsgType != MsgInteractive { return nil, ErrMessageType @@ -308,7 +308,7 @@ func (bot Bot) UpdateMessage(messageID string, om OutcomingMessage) (*UpdateMess return &respData, err } -// GetMessage posts message with im/v1 +// GetMessage gets a message with im/v1 func (bot Bot) GetMessage(messageID string) (*GetMessageResponse, error) { var respData GetMessageResponse err := bot.GetAPIRequest("GetMessage", fmt.Sprintf(getMessageURL, messageID), true, nil, &respData) @@ -354,7 +354,7 @@ func (bot Bot) DeleteEphemeralMessage(messageID string) (*DeleteEphemeralMessage return &respData, err } -// PinMessage pin a message +// PinMessage pins a message func (bot Bot) PinMessage(messageID string) (*PinMessageResponse, error) { params := map[string]interface{}{ "message_id": messageID, @@ -364,7 +364,7 @@ func (bot Bot) PinMessage(messageID string) (*PinMessageResponse, error) { return &respData, err } -// UnpinMessage unpin a message +// UnpinMessage unpins a message func (bot Bot) UnpinMessage(messageID string) (*UnpinMessageResponse, error) { url := fmt.Sprintf(unpinMessageURL, messageID) var respData UnpinMessageResponse diff --git a/api_message_test.go b/api_message_test.go index c79e781..652e667 100644 --- a/api_message_test.go +++ b/api_message_test.go @@ -452,11 +452,11 @@ func TestReactionMessage(t *testing.T) { resp, err := bot.PostMessage(om) if assert.NoError(t, err) { messageID := resp.Data.MessageID - resp, err := bot.ReactionMessage(messageID, EmojiTypeOK) + resp, err := bot.AddReaction(messageID, EmojiTypeOK) if assert.NoError(t, err) { assert.Equal(t, 0, resp.Code) assert.Equal(t, EmojiTypeOK, resp.Data.ReactionType.EmojiType) - deleteReactionResp, err := bot.DeleteReactionMessage(messageID, resp.Data.ReactionID) + deleteReactionResp, err := bot.DeleteReaction(messageID, resp.Data.ReactionID) assert.NoError(t, err) assert.Equal(t, 0, deleteReactionResp.Code) }