mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-08 20:39:36 +08:00
Remove val previous
This commit is contained in:
parent
d3d7e530a9
commit
a113f0ed1e
@ -71,7 +71,7 @@ fun Application.mirai() {
|
||||
routing {
|
||||
mirai("/sendFriendMessage") {
|
||||
// TODO: 2019/11/21 解析图片消息等为 Message
|
||||
Bot.instanceWhose(qq = param("bot")).getQQ(param("qq")).sendMessage(param<String>("message"))
|
||||
Bot.instanceWhose(qq = param("bot")).getFriend(param("qq")).sendMessage(param<String>("message"))
|
||||
call.ok()
|
||||
}
|
||||
|
||||
|
@ -8,20 +8,9 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
|
||||
class FriendMessage(
|
||||
bot: Bot,
|
||||
/**
|
||||
* 是否是在这次登录之前的消息, 即消息记录
|
||||
*/
|
||||
val previous: Boolean,
|
||||
override val sender: QQ,
|
||||
override val message: MessageChain
|
||||
) : MessagePacket<QQ, QQ>(bot), BroadcastControllable {
|
||||
/**
|
||||
* 是否应被自动广播. 此为内部 API
|
||||
*/
|
||||
@MiraiInternalAPI
|
||||
override val shouldBroadcast: Boolean
|
||||
get() = !previous
|
||||
|
||||
override val subject: QQ get() = sender
|
||||
|
||||
override fun toString(): String = "FriendMessage(sender=${sender.id}, message=$message)"
|
||||
|
@ -4,7 +4,9 @@ package net.mamoe.mirai.message
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.contact.*
|
||||
import net.mamoe.mirai.contact.Contact
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.QQ
|
||||
import net.mamoe.mirai.data.EventPacket
|
||||
import net.mamoe.mirai.event.events.BotEvent
|
||||
import net.mamoe.mirai.message.data.*
|
||||
@ -71,12 +73,19 @@ abstract class MessagePacketBase<TSender : QQ, TSubject : Contact>(_bot: Bot) :
|
||||
|
||||
// region Image download
|
||||
suspend inline fun Image.downloadAsByteArray(): ByteArray = bot.run { downloadAsByteArray() }
|
||||
|
||||
suspend inline fun Image.download(): ByteReadPacket = bot.run { download() }
|
||||
// endregion
|
||||
|
||||
fun At.qq(): QQ = bot.getQQ(this.target)
|
||||
@Deprecated(message = "这个函数有歧义, 将在不久后删除", replaceWith = ReplaceWith("bot.getFriend(this.target)"))
|
||||
fun At.qq(): QQ = bot.getFriend(this.target)
|
||||
|
||||
fun Int.qq(): QQ = bot.getQQ(this.coerceAtLeastOrFail(0).toLong())
|
||||
fun Long.qq(): QQ = bot.getQQ(this.coerceAtLeastOrFail(0))
|
||||
@Deprecated(message = "这个函数有歧义, 将在不久后删除", replaceWith = ReplaceWith("bot.getFriend(this.toLong())"))
|
||||
fun Int.qq(): QQ = bot.getFriend(this.coerceAtLeastOrFail(0).toLong())
|
||||
|
||||
@Deprecated(message = "这个函数有歧义, 将在不久后删除", replaceWith = ReplaceWith("bot.getFriend(this)"))
|
||||
fun Long.qq(): QQ = bot.getFriend(this.coerceAtLeastOrFail(0))
|
||||
|
||||
@Deprecated(message = "这个函数有歧义, 将在不久后删除", replaceWith = ReplaceWith("bot.getGroup(this)"))
|
||||
fun Long.group(): Group = bot.getGroup(this)
|
||||
}
|
Loading…
Reference in New Issue
Block a user