Style One | |
Style Two | |
addMessageReaction
interface to add an emoji to a message. After a successful addition, the emoji will store the information of the user who performed the operation.removeMessageReaction
interface to delete an already added emoji. After successful deletion, the emoji will no longer store the information of the user who performed the operation.getMessageReactions
interface to batch retrieve the emoji list of multiple messages, where each emoji includes the total number of users currently using it and the profiles of the first N (default 10) users.getAllUserListOfMessageReaction
interface to paginate and retrieve the complete list of user profiles for users of a message emoji.TencentCloudChat.EVENT.MESSAGE_REACTIONS_UPDATE
event to detect changes in the user information of emoji users. This event will carry the latest user information of the emoji (including the total number of users and the profiles of the top N users).addMessageReaction
interface, you can add a message response.chat.addMessageReaction(message, reactionID);
Attribute | Meaning | Description |
message | Message object | The message is sent successfully. |
reactionID | Message Response ID | In emoji response scenarios, the reactionID is the Emoji ID. |
Promise
let promise = chat.addMessageReaction(message, 'smile');promise.then(function(imResponse) {// Message Response Added Successfully}).catch(function(imError) {// Failed to add message responseconsole.warn('addMessageReaction error:', imError);});
removeMessageReaction
API to delete a message response.chat.removeMessageReaction(message, reactionID);
Attribute | Meaning | Description |
message | Message object | The message is sent successfully. |
reactionID | Message Response ID | In emoji response scenarios, the reactionID is the Emoji ID. |
Promise
let promise = chat.removeMessageReaction(message, 'smile');promise.then(function(imResponse) {// Message response deleted successfully}).catch(function(imError) {// Delete message response failedconsole.warn('removeMessageReaction error:', imError);});
getMessageReactions
interface to batch retrieve multiple message response information.chat.getMessageReactions(options);
Attribute | Meaning | Description |
messageList | Message list | Messages must belong to the same session and must be in a successfully sent state. |
maxUserCountPerReaction | The maximum number of user profiles returned for each Reaction | Value range [0,10], each Reaction returns the profiles of up to the first 10 users only. For more user profiles, You can call the getAllUserListOfMessageReaction interface as needed for pagination retrieval. |
Promise
let promise = chat.getMessageReactions({messageList: [message1, message2],maxUserCountPerReaction: 10,});promise.then(function(imResponse) {// Batch retrieval successfulconst resultList = imResponse.data;resultList.forEach((item) => {const { messageID, reactionList } = item;// The information returned by reactionList is as follows:// reactionID - Message Response ID// totalUserCount - Total number of users who responded to the same reactionID message// partialUserList - A partial list of users with the same reactionID, containing user's userID, nick, avatar information});}).catch(function(imError) {// Batch retrieval failedconsole.warn('getMessageReactions error:', imError);});
getAllUserListOfMessageReaction
interface for pagination retrieval of the full message response user list.chat.getAllUserListOfMessageReaction(options);
Attribute | Meaning | Description |
message | Message object | The message is sent successfully. |
reactionID | Message Response ID | In emoji response scenarios, the reactionID is the Emoji ID. |
nextSeq | Pagination retrieval cursor | For the first transmission, pass 0, then for paging, pass the nextSeq returned by succ. |
count | Maximum number of items that can be pulled in a single page | Supports up to 100 |
Promise
let promise = chat.getAllUserListOfMessageReaction({message: message,reactionID: 'smile',nextSeq: 0,count: 100,});promise.then(function(imResponse) {// Obtained successfullyconst { userList, nextSeq, isCompleted } = imResponse.data;// userList - User Information List, including user's userID, nick, avatar information// nextSeq - This parameter must be passed in for the next pull by page// isCompleted - Indicates whether all user information has been pulled. When isCompleted is true, nextSeq is 0}).catch(function(imError) {// Failed to obtainconsole.warn('getAllUserListOfMessageReaction error:', imError);});
TencentCloudChat.EVENT.MESSAGE_REACTIONS_UPDATED
event. You can obtain the updated message response information in the registered callback.let onMessageReactionsUpdated = function(event) {const { messageID, reactionList } = event.data;// messageID - Message ID// reactionList - Message Response Update ListreactionList.forEach((item) => {const { reactionID, totalUserCount, partialUserList } = item;// reactionID - Message Response ID// totalUserCount - Total number of users who responded to the same reactionID message// partialUserList - A partial list of users with the same reactionID});};chat.on(TencentCloudChat.EVENT.MESSAGE_REACTIONS_UPDATED, onMessageReactionsUpdated);
Was this page helpful?