mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-22 01:49:12 +08:00
Adjust jvm method visibility
This commit is contained in:
parent
f95a11a248
commit
1d34f3e8a0
@ -2,6 +2,7 @@ package compatibility;
|
||||
|
||||
import net.mamoe.mirai.Bot;
|
||||
import net.mamoe.mirai.BotFactoryJvm;
|
||||
import net.mamoe.mirai.message.data.MessageUtils;
|
||||
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
@ -15,6 +16,9 @@ public class CompatibilityTest {
|
||||
public static void main(String[] args) {
|
||||
Bot bot = BotFactoryJvm.newBot(Long.parseLong(System.getenv("qq")), System.getenv("password"));
|
||||
|
||||
bot.getFriend(123).sendMessage(MessageUtils.newChain("")
|
||||
.plus("")
|
||||
.plus(MessageUtils.newImage("")));
|
||||
bot.getFriend(123).sendMessage("");
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import net.mamoe.mirai.contact.nameCardOrNick
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmStatic
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
|
||||
/**
|
||||
@ -60,5 +61,6 @@ private constructor(val target: Long, val display: String) : Message, MessageCon
|
||||
/**
|
||||
* At 这个成员
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun Member.at(): At = At(this)
|
@ -10,7 +10,7 @@
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("MessageUtils")
|
||||
|
||||
@file:Suppress("EXPERIMENTAL_API_USAGE")
|
||||
@file:Suppress("EXPERIMENTAL_API_USAGE", "unused")
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
@ -25,6 +25,7 @@ import net.mamoe.mirai.utils.io.chunkedHexToBytes
|
||||
import kotlin.js.JsName
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
/**
|
||||
* 自定义表情 (收藏的表情), 图片
|
||||
@ -42,6 +43,9 @@ interface Image : Message, MessageContent {
|
||||
val imageId: String
|
||||
}
|
||||
|
||||
/**
|
||||
* 请查看 `ExternalImageJvm` 获取更多创建 [Image] 的方法
|
||||
*/
|
||||
@Suppress("FunctionName")
|
||||
@JsName("newImage")
|
||||
@JvmName("newImage")
|
||||
@ -101,11 +105,15 @@ interface OfflineImage : Image
|
||||
/**
|
||||
* 原图下载链接. 包含域名
|
||||
*/
|
||||
suspend fun OfflineImage.queryOriginUrl(): String {
|
||||
@JvmSynthetic
|
||||
suspend fun OfflineImage.queryUrl(): String {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
return BotImpl.instances.peekFirst().get()?.queryImageUrl(this) ?: error("No Bot available to query image url")
|
||||
}
|
||||
|
||||
@Deprecated("use queryUrl() instead", ReplaceWith("queryUrl()"), level = DeprecationLevel.ERROR)
|
||||
@JvmSynthetic
|
||||
suspend inline fun OfflineImage.queryOriginUrl(): String = queryUrl()
|
||||
// endregion 离线图片
|
||||
|
||||
// region 群图片
|
||||
|
@ -17,6 +17,7 @@ import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.utils.LazyProperty
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
/**
|
||||
* 消息源, 它存在于 [MessageChain] 中, 用于表示这个消息的来源.
|
||||
@ -81,13 +82,17 @@ interface MessageSource : Message, MessageMetadata {
|
||||
* 序列号. 若是机器人发出去的消息, 请先 [确保 sequenceId 可用][MessageSource.ensureSequenceIdAvailable]
|
||||
* @see MessageSource.id
|
||||
*/
|
||||
val MessageSource.sequenceId: Int get() = (this.id shr 32).toInt()
|
||||
@get:JvmSynthetic
|
||||
inline val MessageSource.sequenceId: Int
|
||||
get() = (this.id shr 32).toInt()
|
||||
|
||||
/**
|
||||
* 消息随机数. 由服务器或客户端指定后不能更改. 它是消息 id 的一部分.
|
||||
* @see MessageSource.id
|
||||
*/
|
||||
val MessageSource.messageRandom: Int get() = this.id.toInt()
|
||||
@get:JvmSynthetic
|
||||
inline val MessageSource.messageRandom: Int
|
||||
get() = this.id.toInt()
|
||||
|
||||
// For MessageChain
|
||||
|
||||
@ -95,16 +100,22 @@ val MessageSource.messageRandom: Int get() = this.id.toInt()
|
||||
* 消息 id.
|
||||
* @see MessageSource.id
|
||||
*/
|
||||
val MessageChain.id: Long get() = this[MessageSource].id
|
||||
@get:JvmSynthetic
|
||||
inline val MessageChain.id: Long
|
||||
get() = this[MessageSource].id
|
||||
|
||||
/**
|
||||
* 消息序列号, 可能来自服务器也可以发送时赋值, 不唯一.
|
||||
* @see MessageSource.id
|
||||
*/
|
||||
val MessageChain.sequenceId: Int get() = this[MessageSource].sequenceId
|
||||
@get:JvmSynthetic
|
||||
inline val MessageChain.sequenceId: Int
|
||||
get() = this[MessageSource].sequenceId
|
||||
|
||||
/**
|
||||
* 消息随机数. 由服务器或客户端指定后不能更改. 它是消息 id 的一部分.
|
||||
* @see MessageSource.id
|
||||
*/
|
||||
val MessageChain.messageRandom: Int get() = this[MessageSource].messageRandom
|
||||
@get:JvmSynthetic
|
||||
inline val MessageChain.messageRandom: Int
|
||||
get() = this[MessageSource].messageRandom
|
||||
|
@ -16,6 +16,7 @@ package net.mamoe.mirai.message.data
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmStatic
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
/**
|
||||
* 纯文本. 可含 emoji 表情.
|
||||
@ -48,5 +49,6 @@ inline class PlainText(val stringValue: String) : Message, MessageContent {
|
||||
/**
|
||||
* 构造 [PlainText]
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun String.toMessage(): PlainText = PlainText(this)
|
@ -18,6 +18,7 @@ import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
/**
|
||||
* XML 消息, 如分享, 卡片等.
|
||||
@ -37,6 +38,7 @@ class XmlMessage constructor(override val content: String) : RichMessage {
|
||||
/**
|
||||
* 构造一条 XML 消息
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@SinceMirai("0.27.0")
|
||||
@MiraiExperimentalAPI
|
||||
inline fun buildXMLMessage(block: @XMLDsl XMLMessageBuilder.() -> Unit): XmlMessage =
|
||||
|
Loading…
Reference in New Issue
Block a user