Commit a113f0ed authored by Him188's avatar Him188

Remove `val previous`

parent d3d7e530
...@@ -71,7 +71,7 @@ fun Application.mirai() { ...@@ -71,7 +71,7 @@ fun Application.mirai() {
routing { routing {
mirai("/sendFriendMessage") { mirai("/sendFriendMessage") {
// TODO: 2019/11/21 解析图片消息等为 Message // 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() call.ok()
} }
......
...@@ -8,20 +8,9 @@ import net.mamoe.mirai.utils.MiraiInternalAPI ...@@ -8,20 +8,9 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
class FriendMessage( class FriendMessage(
bot: Bot, bot: Bot,
/**
* 是否是在这次登录之前的消息, 即消息记录
*/
val previous: Boolean,
override val sender: QQ, override val sender: QQ,
override val message: MessageChain override val message: MessageChain
) : MessagePacket<QQ, QQ>(bot), BroadcastControllable { ) : MessagePacket<QQ, QQ>(bot), BroadcastControllable {
/**
* 是否应被自动广播. 此为内部 API
*/
@MiraiInternalAPI
override val shouldBroadcast: Boolean
get() = !previous
override val subject: QQ get() = sender override val subject: QQ get() = sender
override fun toString(): String = "FriendMessage(sender=${sender.id}, message=$message)" override fun toString(): String = "FriendMessage(sender=${sender.id}, message=$message)"
......
...@@ -4,7 +4,9 @@ package net.mamoe.mirai.message ...@@ -4,7 +4,9 @@ package net.mamoe.mirai.message
import kotlinx.io.core.ByteReadPacket import kotlinx.io.core.ByteReadPacket
import net.mamoe.mirai.Bot 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.data.EventPacket
import net.mamoe.mirai.event.events.BotEvent import net.mamoe.mirai.event.events.BotEvent
import net.mamoe.mirai.message.data.* import net.mamoe.mirai.message.data.*
...@@ -71,12 +73,19 @@ abstract class MessagePacketBase<TSender : QQ, TSubject : Contact>(_bot: Bot) : ...@@ -71,12 +73,19 @@ abstract class MessagePacketBase<TSender : QQ, TSubject : Contact>(_bot: Bot) :
// region Image download // region Image download
suspend inline fun Image.downloadAsByteArray(): ByteArray = bot.run { downloadAsByteArray() } suspend inline fun Image.downloadAsByteArray(): ByteArray = bot.run { downloadAsByteArray() }
suspend inline fun Image.download(): ByteReadPacket = bot.run { download() } suspend inline fun Image.download(): ByteReadPacket = bot.run { download() }
// endregion // 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)
@Deprecated(message = "这个函数有歧义, 将在不久后删除", replaceWith = ReplaceWith("bot.getFriend(this.toLong())"))
fun Int.qq(): QQ = bot.getFriend(this.coerceAtLeastOrFail(0).toLong())
fun Int.qq(): QQ = bot.getQQ(this.coerceAtLeastOrFail(0).toLong()) @Deprecated(message = "这个函数有歧义, 将在不久后删除", replaceWith = ReplaceWith("bot.getFriend(this)"))
fun Long.qq(): QQ = bot.getQQ(this.coerceAtLeastOrFail(0)) fun Long.qq(): QQ = bot.getFriend(this.coerceAtLeastOrFail(0))
@Deprecated(message = "这个函数有歧义, 将在不久后删除", replaceWith = ReplaceWith("bot.getGroup(this)"))
fun Long.group(): Group = bot.getGroup(this)
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment