mirai-core / net.mamoe.mirai.contact / Member / sendMessage

sendMessage

abstract suspend fun sendMessage(message: Message): MessageReceipt<Member>

向群成员发送消息. 若群成员同时是好友, 则会发送好友消息. 否则发送临时会话消息.

单条消息最大可发送 4500 字符或 50 张图片.

Exceptions

EventCancelledException - 当发送消息事件被取消时抛出

BotIsBeingMutedException - 发送群消息时若 Bot 被禁言抛出

MessageTooLargeException - 当消息过长时抛出

IllegalArgumentException - 当消息内容为空时抛出 (详见 Message.isContentEmpty)

See Also

MessageSendEvent.FriendMessageSendEvent

MessageSendEvent.GroupMessageSendEvent

Return
消息回执. 可进行撤回 (MessageReceipt.recall)

suspend fun sendMessage(message: String): MessageReceipt<Member>

See Also

sendMessage