Options
All
  • Public
  • Public/Protected
  • All
Menu

Module nim/MessageInterface

Index

Type aliases

NIMClientAntispamResult: { operateType: NIMClientAntispamOperateType; replacedText: string }

Type declaration

NIMMessageAIConfig: { accountId: string; aiRAGs?: NIMAIRAGInfo[]; aiStatus?: number; aiStream: boolean; aiStreamLastChunk?: NIMMessageAIStreamChunk; aiStreamStatus: NIMMessageAIStreamStatus }

消息体中的 AI 数字人相关配置

Type declaration

  • accountId: string

    AI 数字人的账号

  • Optional aiRAGs?: NIMAIRAGInfo[]

    数字人回复内容的引用资源列表

  • Optional aiStatus?: number

    该 AI 消息的询问和应答标识

    0 表示普通消息
    1 表示是一个艾特数字人的消息
    2 表示是数字人响应艾特的消息

  • aiStream: boolean

    是否是流式响应,默认false

  • Optional aiStreamLastChunk?: NIMMessageAIStreamChunk

    数字人流式消息收到的最近一个分片.

    注: 如果消息已完整, 那么该字段为空

  • aiStreamStatus: NIMMessageAIStreamStatus

    数字人流式消息状态

NIMMessageAIConfigParams: { accountId: string; aiStream?: boolean; content?: NIMAIModelCallContent; messages?: NIMAIModelCallMessage[]; modelConfigParams?: NIMAIModelConfigParams; promptVariables?: string }

发送消息时,与数字人相关的参数

Type declaration

  • accountId: string

    AI 数字人的账号

  • Optional aiStream?: boolean

    是否流式返回. 默认 false

  • Optional content?: NIMAIModelCallContent

    请求大模型的内容.

  • Optional messages?: NIMAIModelCallMessage[]

    上下文内容

    注: 当前只支持文本消息

  • Optional modelConfigParams?: NIMAIModelConfigParams

    请求接口模型相关参数配置

  • Optional promptVariables?: string

    提示词变量占位符替换. JSON 序列化的字符串

    注: 如果 NIMAIUser 中的 modelConfig.promptKeys 存在且数组长度不为 0 ,则必填.

NIMMessageAIRegenParams: { operationType: NIMMessageAIRegenOpType }

Type declaration

NIMMessageAIStreamChunk: { chunkTime: number; content: string; index: number; messageTime: number; type: number }

Type declaration

  • chunkTime: number

    数字人流式回复当前分片时间

  • content: string

    数字人流式回复分片文本

  • index: number

    分片序号,从0开始

  • messageTime: number

    数字人流式消息时间,即占位消息时间

  • type: number

    类型,当前仅支持0表示文本

NIMMessageAIStreamStopParams: { operationType: NIMMessageAIStreamStopOpType; updateContent?: string }

Type declaration

  • operationType: NIMMessageAIStreamStopOpType

    停止流式消息的操作类型

  • Optional updateContent?: string

    更新的消息内容.

    注: 仅当 operationType === NIM_MESSAGE_AI_STREAM_STOP_OP_UPDATE 时有效

NIMMessageAntispamConfig: { antispamBusinessId?: string; antispamCheating?: string; antispamCustomMessage?: string; antispamEnabled?: boolean; antispamExtension?: string }

Type declaration

  • Optional antispamBusinessId?: string

    指定易盾业务id

  • Optional antispamCheating?: string

    易盾反作弊,辅助检测数据,json格式

  • Optional antispamCustomMessage?: string

    自定义消息中需要反垃圾的内容,仅当消息类型为自定义消息时有效

    内容必须为 json 格式,格式如下:

    {
    // 1 文本 2 图片 3 视频
    "type": 1
    // 文本内容;图片地址;视频地址
    "data": ""
    }
  • Optional antispamEnabled?: boolean

    指定消息是否需要经过安全通。默认为 true

    对于已开通安全通的用户有效,默认消息都会走安全通,如果对单条消息设置 enable 为 false,则此消息不会走安全通

  • Optional antispamExtension?: string

    易盾反垃圾,增强检测数据,json格式

NIMMessagePushConfig: { forcePush?: boolean; forcePushAccountIds?: string[]; forcePushContent?: string; pushContent?: string; pushEnabled?: boolean; pushNickEnabled?: boolean; pushPayload?: string }

Type declaration

  • Optional forcePush?: boolean

    是否需要强制推送,忽略用户消息提醒相关设置。该设置仅在群聊时有效。默认为 false

  • Optional forcePushAccountIds?: string[]

    强制推送目标账号列表。该设置仅在群聊时有效

    注: 不存在则代表着强推给所有人. 空数组代表没有强推目标. 数组有值代表强推给指定的若干个账号

  • Optional forcePushContent?: string

    强制推送文案。该设置仅在群聊时有效

  • Optional pushContent?: string

    推送文案

  • Optional pushEnabled?: boolean

    是否需要推送消息。默认为 true

  • Optional pushNickEnabled?: boolean

    是否需要推送消息发送者昵称。默认 true

  • Optional pushPayload?: string

    推送自定义 pushPayload

NIMMessageRouteConfig: { routeEnabled?: boolean; routeEnvironment?: string }

Type declaration

  • Optional routeEnabled?: boolean

    是否需要路由消息(抄送)。默认为 true

  • Optional routeEnvironment?: string

    环境变量,用于指向不同的抄送,第三方回调等配置

NIMMessageStreamChunk: { chunkTime: number; content: string; index: number; messageTime: number; type: number }

Type declaration

  • chunkTime: number

    流式回复当前分片时间

  • content: string

    流式回复分片文本

  • index: number

    分片序号,从0开始

  • messageTime: number

    流式消息时间,即占位消息时间

  • type: number

    类型,当前仅支持0表示文本

NIMMessageStreamConfig: { lastChunk?: NIMMessageStreamChunk; rags?: NIMAIRAGInfo[]; status: NIMMessageStreamStatus }

Type declaration

NIMModifyMessageParams: { antispamConfig?: NIMMessageAntispamConfig; attachment?: NIMMessageAttach; clientAntispamEnabled?: boolean; clientAntispamReplace?: string; pushConfig?: NIMMessagePushConfig; routeConfig?: NIMMessageRouteConfig; serverExtension?: string; subType?: number; text?: string }

Type declaration

  • Optional antispamConfig?: NIMMessageAntispamConfig

    反垃圾相关配置

  • Optional attachment?: NIMMessageAttach

    消息附属附件.

    注: 仅允许定位、tip、自定义消息去更新附件信息

  • Optional clientAntispamEnabled?: boolean

    是否启用本地反垃圾. 默认 false.

    注: 若想启用本字段, 推荐在初始化登录完毕后调用 nim.getClientAntispamLexicon() 先行获取本地反垃圾词库.

    • 发送消息时候,如果为 true,则先本地反垃圾检测,检测后返回 NIMClientAntispamOperateType

    本地反垃圾有四种结果:

    • 直接发送消息
    • 发送替换后的文本
    • 消息发送失败,返回本地错误码
    • 消息正常发送,由服务器拦截
  • Optional clientAntispamReplace?: string

    反垃圾命中后的替换文本.

    注: 截至 v9.20.15 这个字段不起作用, 因为固定了为 "**"

  • Optional pushConfig?: NIMMessagePushConfig

    推送相关配置

  • Optional routeConfig?: NIMMessageRouteConfig

    路由抄送相关配置

  • Optional serverExtension?: string

    消息服务端扩展. 请使用 JSON 序列化的字符串

  • Optional subType?: number

    消息子类型.

  • Optional text?: string

    消息内容

NIMModifyMessageResult: { antispamResult?: string; clientAntispamResult?: NIMClientAntispamResult; errorCode: number; message?: NIMMessage }

Type declaration

  • Optional antispamResult?: string

    云端反垃圾返回的结果

  • Optional clientAntispamResult?: NIMClientAntispamResult

    客户端本地反垃圾结果

  • errorCode: number

    默认为 200

    注: 如果此错误码为非 200,表示修改消息失败(比如触发了云端反垃圾), 此时修改成功后的消息体返回为空

  • Optional message?: NIMMessage

    修改成功后的消息体

NIMMsgAttachAcceptTeamInvite: { account: string; members: NIMTeamMember[]; team: NIMTeam; type: "acceptTeamInvite" | "acceptSuperTeamInvite"; users: NIMUserNameCard[] }

同意群邀请时的通知消息

Type declaration

  • account: string

    邀请人账号

  • members: NIMTeamMember[]

    新加入的成员信息。注意该信息是成员在群里的信息

  • team: NIMTeam

    群信息

  • type: "acceptTeamInvite" | "acceptSuperTeamInvite"
  • users: NIMUserNameCard[]

    邀请人和接受邀请的人的名片

NIMMsgAttachAddTeamManagers: { accounts: string[]; members: NIMTeamMember[]; team: NIMTeam; type: "addTeamManagers" | "addSuperTeamManagers"; users: NIMUserNameCard[] }

添加群管理员时的通知消息

Type declaration

  • accounts: string[]

    新增管理员账号列表

  • members: NIMTeamMember[]

    新增管理员在群里的信息

  • team: NIMTeam

    群信息

  • type: "addTeamManagers" | "addSuperTeamManagers"
  • users: NIMUserNameCard[]

    新增管理员的名片,以及操作者名片

NIMMsgAttachAddTeamMember: { accounts: string[]; members: NIMTeamMember[]; team: NIMTeam; type: "addTeamMembers" | "addSuperTeamMembers"; users: NIMUserNameCard[] }

添加群成员时候的通知消息

Type declaration

  • accounts: string[]

    新加入的成员账号

  • members: NIMTeamMember[]

    新加入的成员信息。注意该信息是成员在群里的信息

  • team: NIMTeam

    群信息

  • type: "addTeamMembers" | "addSuperTeamMembers"
  • users: NIMUserNameCard[]

    操作者和被操作者的名片

NIMMsgAttachDismissTeam: { type: "dismissTeam" | "dismissSuperTeam"; users: NIMUserNameCard[] }

Type declaration

  • type: "dismissTeam" | "dismissSuperTeam"
  • users: NIMUserNameCard[]

    解散者名片信息

NIMMsgAttachLeaveTeam: { team: NIMTeam; type: "leaveTeam" | "leaveSuperTeam"; users: NIMUserNameCard[] }

离开群组时的通知消息

Type declaration

NIMMsgAttachPassTeamApply: { account: string; members: NIMTeamMember[]; team: NIMTeam; type: "passTeamApply" | "passSuperTeamApply"; users: NIMUserNameCard[] }

通过群申请时的通知消息

Type declaration

  • account: string

    申请人账号

  • members: NIMTeamMember[]

    新加入的成员信息。注意该信息是成员在群里的信息

  • team: NIMTeam

    群信息

  • type: "passTeamApply" | "passSuperTeamApply"
  • users: NIMUserNameCard[]

    申请人和同意申请人的名片

NIMMsgAttachRemoveTeamManagers: { accounts: string[]; members: NIMTeamMember[]; team: NIMTeam; type: "removeTeamManagers" | "removeSuperTeamManagers"; users: NIMUserNameCard[] }

删除群管理员时的通知消息

Type declaration

  • accounts: string[]

    被移除管理员账号列表

  • members: NIMTeamMember[]

    被移除管理员在群里的信息

  • team: NIMTeam

    群信息

  • type: "removeTeamManagers" | "removeSuperTeamManagers"
  • users: NIMUserNameCard[]

    被移除管理员的名片,以及操作者名片

NIMMsgAttachRemoveTeamMembers: { accounts: string[]; team: NIMTeam; type: "removeTeamMembers" | "removeSuperTeamMembers"; users: NIMUserNameCard[] }

删除群成员时候的通知消息

Type declaration

  • accounts: string[]

    被删除的成员账号

  • team: NIMTeam

    群信息

  • type: "removeTeamMembers" | "removeSuperTeamMembers"
  • users: NIMUserNameCard[]

    操作者和被操作者的名片

NIMMsgAttachTransferTeam: { account: string; members: NIMTeamMember[]; team: NIMTeam; type: "transferTeam" | "transferSuperTeam"; users: NIMUserNameCard[] }

转让群组时的通知消息

Type declaration

  • account: string

    原群主

  • members: NIMTeamMember[]

    新老群主在群内信息

  • team: NIMTeam

    群信息

  • type: "transferTeam" | "transferSuperTeam"
  • users: NIMUserNameCard[]

    新老群主名片信息

NIMMsgAttachUpdateSuperTeamMembersMute: { accounts: string[]; members: NIMTeamMember[]; mute: boolean; team: NIMTeam; type: "updateSuperTeamMembersMute"; users: NIMUserNameCard[] }

更新超级群成员禁言状态时的通知消息 (updateSuperTeamMembersMute)

Type declaration

  • accounts: string[]

    被禁言/解除禁言者的账号

  • members: NIMTeamMember[]

    被禁言/解除禁言者的群成员信息

  • mute: boolean

    指定群成员是否被禁言

  • team: NIMTeam

    群信息

  • type: "updateSuperTeamMembersMute"
  • users: NIMUserNameCard[]

    被禁言/解除禁言者的名片 + 操作者的名片

NIMMsgAttachUpdateTeam: { team: Partial<NIMTeam>; type: "updateTeam" | "updateSuperTeam"; users: NIMUserNameCard[] }

更新群,禁言群时的通知消息

Type declaration

NIMMsgAttachUpdateTeamMute: { account: string; members: NIMTeamMember[]; mute: boolean; team: NIMTeam; type: "updateTeamMute"; users: NIMUserNameCard[] }

更新群成员禁言状态时的通知消息 (updateMuteStateInTeam)

Type declaration

  • account: string

    被禁言/解除禁言者的账号

  • members: NIMTeamMember[]

    被禁言/解除禁言者的群成员信息

  • mute: boolean

    指定群成员是否被禁言

  • team: NIMTeam

    群信息

  • type: "updateTeamMute"
  • users: NIMUserNameCard[]

    被禁言/解除禁言者的名片 + 操作者的名片

NIMMsgScene: keyof typeof NIMEnumMsgScene

消息的场景

NIMMsgType: keyof typeof NIMEnumMsgType
NIMP2PMsgReceipt: { idClient: string; msgReceiptTime: number; sessionId: string }

Type declaration

  • idClient: string

    消息的 idServer

  • msgReceiptTime: number

    消息被读时间

  • sessionId: string
NIMTeamMsgReceipt: { account: string; idClient: string; idServer: string; read: number; teamId: string; unread: number }

Type declaration

  • account: string

    当前标记 receipt 者的账号 account ID

  • idClient: string

    消息的 idServer

  • idServer: string

    消息的 idServer

  • read: number

    当前已标记 receipt 的人数

  • teamId: string
  • unread: number

    当前未标记 receipt 的人数