mirai-core / net.mamoe.mirai.utils

Package net.mamoe.mirai.utils

Types

BotConfiguration

Bot 配置

open class BotConfiguration

Context

On Android, typealias to android.content.Context On JVM, empty class.

abstract class Context

ContextImpl

open class ContextImpl : Context

DefaultLoginSolver

自动选择 SwingSolverStandardCharImageLoginSolver

class DefaultLoginSolver : LoginSolver

DeviceInfo

设备信息. 可通过继承 SystemDeviceInfo 来在默认的基础上修改

abstract class DeviceInfo

DeviceInfoData

class DeviceInfoData : DeviceInfo

ExternalImage

外部图片. 图片数据还没有读取到内存.

class ExternalImage

LockFreeLinkedList

Implementation of lock-free LinkedList.

open class LockFreeLinkedList<E>

LockFreeLinkedListNode

open class LockFreeLinkedListNode<E>

LoginSolver

验证码, 设备锁解决器

abstract class LoginSolver

MiraiLogger

日志记录器. 所有的输出均依赖于它. 不同的对象可拥有只属于自己的 logger. 通过 identity 来区分.

interface MiraiLogger

MiraiLoggerPlatformBase

日志基类. 实现了 follower 的调用传递. 若 Mirai 自带的日志系统无法满足需求, 请继承这个类并实现其抽象函数.

abstract class MiraiLoggerPlatformBase : MiraiLogger

MiraiLoggerWithSwitch

带有开关的 Logger. 仅能通过 MiraiLogger.withSwitch 构造

class MiraiLoggerWithSwitch : MiraiLoggerPlatformBase

PlatformLogger

当前平台的默认的日志记录器. 在 JVM 控制台 端的实现为 printlnAndroid 端的实现为 android.util.Log

open class PlatformLogger : MiraiLoggerPlatformBase

SilentLogger

不做任何事情的 logger, keep silent.

object SilentLogger : PlatformLogger

SimpleLogger

简易日志记录, 所有类型日志都会被重定向 logger

class SimpleLogger : MiraiLoggerPlatformBase

StandardCharImageLoginSolver

使用字符图片展示验证码, 使用 input 获取输入, 使用 overrideLogger 输出

class StandardCharImageLoginSolver : LoginSolver

SwingSolver

object SwingSolver : LoginSolver

SystemDeviceInfo

通过本机信息来获取设备信息.

open class SystemDeviceInfo : DeviceInfo

UnsafeWeakRef

WeakRef that getValue for delegation throws an IllegalStateException if the referent is released by GC. Therefore it returns notnull value only

class UnsafeWeakRef<T>

Annotations

MiraiExperimentalAPI

标记这个类, 类型, 函数, 属性, 字段, 或构造器为实验性的 API.

annotation class MiraiExperimentalAPI

MiraiInternalAPI

标记为一个仅供 Mirai 内部使用的 API.

annotation class MiraiInternalAPI

SinceMirai

标记一个自 Mirai 某个版本起才支持或在这个版本修改过的 API.

annotation class SinceMirai

Throws

This annotation indicates what exceptions should be declared by a function when compiled to a JVM method.

annotation class Throws

WeakRefProperty

Indicates that the property is delegated by a WeakRef

annotation class WeakRefProperty

Exceptions

OverFileSizeMaxException

图片文件过大

class OverFileSizeMaxException : IllegalStateException

Extensions for External Classes

java.awt.image.BufferedImage

java.io.File

java.io.InputStream

java.lang.ref.WeakReference

java.net.URL

kotlin.collections.Iterable

kotlin.Int

kotlin.sequences.Sequence

kotlinx.coroutines.io.ByteReadChannel

kotlinx.io.core.Input

Properties

currentTimeMillis

时间戳

val currentTimeMillis: Long

currentTimeSeconds

val currentTimeSeconds: Long

DefaultLogger

用于创建默认的日志记录器. 在一些需要使用日志的 Mirai 的组件, 如 Bot, 都会通过这个函数构造日志记录器. 可直接修改这个变量的值来重定向日志输出.

var DefaultLogger: (identity: String?) -> MiraiLogger

Functions

asSequence

Builds a Sequence containing all the elements in this in the same order.

fun <E> LockFreeLinkedList<E>.asSequence(): Sequence<E>

debug

fun MiraiLogger.debug(lazyMessage: () -> String?): Unit
fun MiraiLogger.debug(lazyMessage: () -> String?, e: Throwable?): Unit

error

fun MiraiLogger.error(lazyMessage: () -> String?): Unit
fun MiraiLogger.error(lazyMessage: () -> String?, e: Throwable?): Unit

getValue

Provides delegate value.

operator fun <T> UnsafeWeakRef<T>.getValue(thisRef: Any?, property: KProperty<*>): T

info

fun MiraiLogger.info(lazyMessage: () -> String?): Unit
fun MiraiLogger.info(lazyMessage: () -> String?, e: Throwable?): Unit

isRemoved

fun <E> LockFreeLinkedListNode<E>.isRemoved(): Boolean

iterator

operator fun <E> LockFreeLinkedList<E>.iterator(): Iterator<E>

sendImage

将图片作为单独的消息发送给 this

suspend fun <C : Contact> C.sendImage(image: ExternalImage): MessageReceipt<C>

sendTo

将图片作为单独的消息发送给指定联系人

suspend fun <C : Contact> ExternalImage.sendTo(contact: C): MessageReceipt<C>

toList

Collect all the elements into a MutableList then cast it as a List

fun <E> LockFreeLinkedList<E>.toList(): List<E>

toMutableList

Collect all the elements into a MutableList.

fun <E> LockFreeLinkedList<E>.toMutableList(): MutableList<E>

toMutableSet

Collect all the elements into a MutableSet.

fun <E> LockFreeLinkedList<E>.toMutableSet(): MutableSet<E>

toSet

Collect all the elements into a MutableSet then cast it as a Set

fun <E> LockFreeLinkedList<E>.toSet(): Set<E>

unsafeWeakRef

Provides a weak reference to this. The getValue for delegation throws an IllegalStateException if the referent is released by GC. Therefore it returns notnull value only

fun <T> T.unsafeWeakRef(): UnsafeWeakRef<T>

upload

上传图片并通过图片 ID 构造 Image 这个函数可能需消耗一段时间

suspend fun ExternalImage.upload(contact: Contact): OfflineImage

verbose

fun MiraiLogger.verbose(lazyMessage: () -> String): Unit
fun MiraiLogger.verbose(lazyMessage: () -> String, e: Throwable?): Unit

warning

fun MiraiLogger.warning(lazyMessage: () -> String?): Unit
fun MiraiLogger.warning(lazyMessage: () -> String?, e: Throwable?): Unit

weakRef

Provides a weak reference to this The getValue for delegation returns this when this is not released by GC

fun <T> T.weakRef(): WeakRef<T>

withSwitch

给这个 logger 添加一个开关, 用于控制是否记录 log

fun MiraiLogger.withSwitch(default: Boolean = true): MiraiLoggerWithSwitch