Commit 7ffbccb9 authored by Him188's avatar Him188

Misc improvements

parent 7e3ede0d
......@@ -92,6 +92,8 @@ interface Contact : CoroutineScope {
override fun toString(): String
}
suspend inline fun Contact.sendMessage(message: Message) = sendMessage(message.toChain())
@Suppress("UNCHECKED_CAST")
suspend inline fun <C : Contact> C.sendMessage(message: Message): MessageReceipt<C> =
sendMessage(message.toChain()) as? MessageReceipt<C> ?: error("Internal class cast mistake")
suspend inline fun Contact.sendMessage(plain: String) = sendMessage(plain.toMessage())
\ No newline at end of file
suspend inline fun <C : Contact> C.sendMessage(plain: String): MessageReceipt<C> = sendMessage(plain.toMessage())
\ No newline at end of file
......@@ -31,6 +31,7 @@ import java.io.OutputStream
import java.util.stream.Stream
import kotlin.streams.asStream
@UseExperimental(MiraiInternalAPI::class, MiraiExperimentalAPI::class)
internal class BlockingBotImpl(private val bot: Bot) : BlockingBot {
@MiraiInternalAPI
override fun getAccount(): BotAccount = bot.account
......@@ -51,7 +52,6 @@ internal class BlockingBotImpl(private val bot: Bot) : BlockingBot {
override fun getFriend(id: Long): BlockingQQ = bot.getFriend(id).blocking()
override fun queryGroupList(): Stream<Long> = runBlocking { bot.queryGroupList() }.asStream()
@UseExperimental(MiraiInternalAPI::class)
override fun getGroupList(): List<BlockingGroup> = bot.groups.delegate.toList().map { it.blocking() }
override fun queryGroupInfo(code: Long): GroupInfo = runBlocking { bot.queryGroupInfo(code) }
......
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