mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-23 22:00:10 +08:00
Misc improvements
This commit is contained in:
parent
7e3ede0de7
commit
7ffbccb9aa
@ -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())
|
||||
suspend inline fun <C : Contact> C.sendMessage(plain: String): MessageReceipt<C> = sendMessage(plain.toMessage())
|
@ -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) }
|
||||
|
Loading…
Reference in New Issue
Block a user