Parse Message
import { messageParser } from "@relationlabs/im"
const msg: Message
const parsedMsg: ParsedMessage = messageParser(msg)// message type
type MessageType = 'SYS' | 'TEXT' | 'CARD' | 'ANNOUNCEMENT' | 'BATCH_TRANSFER';
// the construct of an original message
type Message = {
type: MessageType;
content: string;
quote?: Message;
}
// the construct generated by parsing a message
type ParsedMessage = {
type: MessageType;
content: string;
parsedContent?: ParsedContent;
quote?: Message;
unidentified?: boolean | undefined;
}
//content parsed
type ParsedContent = string|JoinGroupMessage|ShareMessage|NormalImageMessage|NFTMessage|MentionMessage
// invitation to join a chat group
type JoinGroupMessage = {
groupId: string;
groupName: string;
chatType: 'p2p'|'group'
}
// sharing an URL
type ShareMessage = {
shareUrl: string;
shareName: string;
shareIcon: string;
}
// normal image
type NormalImageMessage = {
imgUrl: string;
s3Key: string;
}
// NFT
type NFTMessage = {
imgUrl: string;
nftChain: string;
}
// to quote a message
type MentionMessage = {
mentionContent: string;
mentionPosition: number[];
}Last updated