Search Messages
Search by Keyword
Search for messages in a specific conversation by keyword.
Method
searchMessages(
type: RCIMIWConversationType,
targetId: string,
channelId: string,
keyword: string,
startTime: number,
count: number,
callback: IRCIMIWSearchMessagesCallback
): Promise<number>;
Parameter Description
Parameter | Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | string | Conversation ID |
channelId | string | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
keyword | string | Keyword to search for |
startTime | number | Search for messages before this timestamp. Pass 0 to start searching from the latest message, moving backward in time. |
count | number | Number of messages to return. Must be greater than 0 and less than or equal to 50. |
callback | IRCIMIWSearchMessagesCallback | Callback for the operation result. |
Return Value
Return Value | Description |
---|---|
number | Status code of the operation. 0 indicates success. For specific results, implement the callback interface. Non-zero values indicate failure, and the callback will not be triggered. Refer to the error codes for details. |
Code Example
const callback = {
onSuccess: (t: Array<RCIMIWMessage>) => {
//...
},
onError: (code: number) => {
//...
},
};
let code = await engine.searchMessages(type, targetId, channelId, keyword, startTime, count, callback);
Search Messages by Time Range
Method
searchMessagesByTimeRange(
type: RCIMIWConversationType,
targetId: string,
channelId: string,
keyword: string,
startTime: number,
endTime: number,
offset: number,
count: number,
callback: IRCIMIWSearchMessagesByTimeRangeCallback
): Promise<number>;
Parameter Description
Parameter | Type | Description |
---|---|---|
type | RCIMIWConversationType | Conversation type |
targetId | string | Conversation ID |
channelId | string | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
keyword | string | Keyword to search for |
startTime | number | Start time |
endTime | number | End time |
offset | number | Offset |
count | number | Number of search results to return. Must be greater than 0 and less than or equal to 50. |
callback | IRCIMIWSearchMessagesByTimeRangeCallback | Callback for the operation result. |
Return Value
Return Value | Description |
---|---|
number | Status code of the operation. 0 indicates success. For specific results, implement the callback interface. Non-zero values indicate failure, and the callback will not be triggered. Refer to the error codes for details. |
Code Example
const callback = {
onSuccess: (t: Array<RCIMIWMessage>) => {
//...
},
onError: (code: number) => {
//...
},
};
let code = await engine.searchMessagesByTimeRange(
type,
targetId,
channelId,
keyword,
startTime,
endTime,
offset,
count,
callback
);
Search Messages by User ID
Method
searchMessagesByUserId(
userId: string,
type: RCIMIWConversationType,
targetId: string,
channelId: string,
startTime: number,
count: number,
callback: IRCIMIWSearchMessagesByUserIdCallback
): Promise<number>;
Parameter Description
Parameter | Type | Description |
---|---|---|
userId | string | User ID |
type | RCIMIWConversationType | Conversation type |
targetId | string | Conversation ID |
channelId | string | Channel ID, only supported for ultra groups. Pass null for other conversation types. |
startTime | number | Start time for the search. Pass 0 to start searching from the latest message, moving backward in time. |
count | number | Number of search results to return. Must be greater than 0 and less than or equal to 50. |
callback | IRCIMIWSearchMessagesByUserIdCallback | Callback for the operation result. |
Return Value
Return Value | Description |
---|---|
number | Status code of the operation. 0 indicates success. For specific results, implement the callback interface. Non-zero values indicate failure, and the callback will not be triggered. Refer to the error codes for details. |
Code Example
const callback = {
onSuccess: (t: Array<RCIMIWMessage>) => {
//...
},
onError: (code: number) => {
//...
},
};
let code = await engine.searchMessagesByUserId(userId, type, targetId, channelId, startTime, count, callback);