Migrate deprecated calls

This commit is contained in:
Him188 2020-12-16 19:21:47 +08:00
parent 4fb3d6c2b3
commit e7632f05d6
3 changed files with 8 additions and 7 deletions

View File

@ -41,7 +41,7 @@ public data class At(
/**
* 构造一个 [At], 仅供内部使用, 否则可能造成消息无法发出的问题.
*/
@Suppress("FunctionName", "UnusedParameter")
@Suppress("FunctionName", "UNUSED_PARAMETER")
@JvmStatic
@LowLevelApi
@Deprecated("Use constructor instead", ReplaceWith("At(target)", "net.mamoe.mirai.message.data.At"))

View File

@ -127,7 +127,7 @@ public interface FileCacheStrategy {
@MiraiExperimentalApi
@Throws(java.io.IOException::class)
override fun newImageCache(input: Input): ExternalImage {
return ExternalImage(createTempFile(directory = directory).apply {
return ExternalImage(File.createTempFile("tmp", null, directory).apply {
deleteOnExit()
input.withOut(this.outputStream()) { copyTo(it) }
}.asReusableInput(true))
@ -136,7 +136,7 @@ public interface FileCacheStrategy {
@MiraiExperimentalApi
@Throws(java.io.IOException::class)
override fun newImageCache(input: InputStream): ExternalImage {
return ExternalImage(createTempFile(directory = directory).apply {
return ExternalImage(File.createTempFile("tmp", null, directory).apply {
deleteOnExit()
input.withOut(this.outputStream()) { copyTo(it) }
}.asReusableInput(true))
@ -150,7 +150,7 @@ public interface FileCacheStrategy {
@MiraiExperimentalApi
override fun newImageCache(input: BufferedImage, format: String): ExternalImage {
val file = createTempFile(directory = directory).apply { deleteOnExit() }
val file = File.createTempFile("tmp", null, directory).apply { deleteOnExit() }
val digest = MessageDigest.getInstance("md5")
digest.reset()
@ -180,7 +180,7 @@ public interface FileCacheStrategy {
@MiraiExperimentalApi
override fun newImageCache(input: URL): ExternalImage {
return ExternalImage(createTempFile(directory = directory).apply {
return ExternalImage(File.createTempFile("tmp", null, directory).apply {
deleteOnExit()
input.openConnection().getInputStream().withOut(this.outputStream()) { copyTo(it) }
}.asReusableInput(true))

View File

@ -112,8 +112,9 @@ public class StandardCharImageLoginSolver(
override suspend fun onSolvePicCaptcha(bot: Bot, data: ByteArray): String? = loginSolverLock.withLock {
val logger = overrideLogger ?: bot.logger
val tempFile: File = createTempFile(suffix = ".png").apply { deleteOnExit() }
@Suppress("BlockingMethodInNonBlockingContext")
withContext(Dispatchers.IO) {
val tempFile: File = File.createTempFile("tmp", ".png").apply { deleteOnExit() }
tempFile.createNewFile()
logger.info("需要图片验证码登录, 验证码为 4 字母")
try {
@ -153,7 +154,7 @@ public class StandardCharImageLoginSolver(
}
}
override suspend fun onSolveUnsafeDeviceLoginVerify(bot: Bot, url: String): String? = loginSolverLock.withLock {
override suspend fun onSolveUnsafeDeviceLoginVerify(bot: Bot, url: String): String = loginSolverLock.withLock {
val logger = overrideLogger ?: bot.logger
logger.info("需要进行账户安全认证")
logger.info("该账户有[设备锁]/[不常用登录地点]/[不常用设备登录]的问题")