Options
All
  • Public
  • Public/Protected
  • All
Menu

调用方式:

qchat.qchatMsg.sendMessage(options)

Hierarchy

  • QChatMsgServiceInterface

Index

Methods

  • 添加一条快捷评论。

    • 快捷评论是一个操作功能,并非一种消息类型。评论内容并非一条消息,而是一个 number 类型,由开发者指定评论内容与界面展示之间的联系。
    • 圈组的快捷评论功能需要在开通圈组功能的基础上额外开通后才能使用。

    影响范围

    • 频道中用户收到 {@link QChatEventInterface.updateQuickComment | updateQuickComment} 圈组内置系统通知
    • 系统通知的 attach.notify.opeType = 1,表示新增快捷评论
    example
    await qchat.qchatMsg.addQuickComment({
    "commentMessage": msg,
    "type": 1
    })

    // 接收方
    qchat.on('systemNotification', notification => {
    console.log(notification.systemNotifications.map(_ => _.type))
    })

    Parameters

    Returns Promise<void>

  • 批量查询消息是否 @ 当前用户

    • 自己发出的消息为 false
    • at 所有人返回 true
    • 被 at 的账号包含本账号返回为 true
    • 被 at 的身份组的账号中的包含自己返回为 true

    注2: 待查询的消息必须为同一服务器下的消息,否则会返回 10414 错误码

    Parameters

    Returns Promise<NIMEQChatAreMentionedMeMessagesResult>

  • 删除某条消息

    注意:

    1. 只有消息的发送者才可以更新这个消息。更新的字段

    2. 返回的内容只是部分的消息体字段

    Parameters

    Returns Promise<Partial<QChatMessage>>

  • 分页获取指定频道的历史消息。

    example
    const messages = await qchat.qchatMsg.getHistoryMessage({
    serverId: 'serverId',
    channelId: 'channelId',
    limit: 100
    })

    Parameters

    Returns Promise<QChatMessage[]>

  • 获取指定服务器下,若干个频道的最后一条消息

    注:被撤回的消息仍旧能被查到,而被删除的消息无法查到

    example
    qchat.qchatMsg.getLastMessageOfChannels({
    "serverId": "serverId",
    "channelIdList": [
    "channel1", "channel2"
    ]
    })

    Parameters

    Returns Promise<QChatGetLastMessageOfChannelsResult>

  • 分页获取某个频道中 @ 当前用户的未读消息列表

    • timestamp 为查询起始时间,传入 0 表示当前时间。查询 ack 到 timestamp时间范围内 at 当前用户的未读消息
    • 默认倒序查询
    example
    const messages = await qchat.qchatMsg.getMentionedMeMessages({
    "serverId": "YOUR_SERVERID",
    "channelId": "YOUR_CHANNELID",
    "timestamp": 0,
    "limit": 200
    })

    Parameters

    Returns Promise<NIMEQChatGetMentionedMeMessagesResults>

  • 标记系统消息已读,下次登陆不会再同步到此通知

    注意:标记已读后,也无法再次修改这条通知。

    Parameters

    Returns Promise<void>

  • 删除一条快捷评论

    影响范围

    • 频道中用户收到 {@link QChatEventInterface.updateQuickComment | updateQuickComment} 圈组内置系统通知
    • 系统通知的 attach.notify.opeType = 2,表示删除快捷评论
    example
    await qchat.qchatMsg.removeQuickComment({
    "commentMessage": msg,
    "type": 1
    })

    // 接收方
    qchat.on('systemNotification', notification => {
    console.log(notification.systemNotifications.map(_ => _.type))
    })

    Parameters

    Returns Promise<void>

  • 如果因为网络等原因发送消息失败(deliveryStatus 为 failed),可调用 resendMessage 方法(调用时传入发送失败的完整的消息体),实现消息重发。

    注意:只有当 QChatMessage 的 deliveryStatus 字段为 failed 时才可以进行重发消息。

    Parameters

    Returns Promise<QChatMessage>

  • 撤回某条消息

    注意:

    1. 只有消息的发送者才可以更新这个消息。更新的字段

    2. 返回的内容只是部分的消息体字段

    Parameters

    Returns Promise<Partial<QChatMessage>>

  • 在频道中发送消息。此接口即包含文本消息,又包含图片、音视频、位置、提示、自定义消息等。

    • 发送方必要拥有发送消息的权限
    • 如果您希望在发送消息前提前得到QChatMessage以便于插入界面中,请使用 SendMessageOptions.onSendBefore 回调方法。
    • 更多文档请参考: 圈组消息收发

    影响范围

    example
    // 接收方
    qchat.on('message', message => {})

    // 发送方
    const msg1 = await qchat.qchatMsg.sendMessage({
    "serverId": "{{YOUR_SERVERID}}",
    "channelId": "{{YOUR_CHANNELID}}",
    "type": "text",
    "body": "This is a test message",
    "mentionAccids": ["accountId1", "accountId2"]
    })

    Parameters

    Returns Promise<QChatMessage>

  • 发送正在输入事件

    注1:API 有节流操作,相同频道每 3s 仅发送一次。

    注2:接收方需要调用 subscribeChannel 来订阅正在输入事件后,才能收到指定频道的正在输入事件

    Parameters

    Returns Promise<void>

  • 更新系统通知

    注意:满足三个条件才可以更新通知,否则返回 414

    1. 该系统通知存离线(msgIdServer 不为 0,且 persistEnable 为 true);

    2. 该系统通知有 toAccids 字段,指定了通知的接收者

    3. 操作人是系统通知的接收者

    Parameters

    Returns Promise<QChatSystemNotification>