mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +08:00
Add copyright
This commit is contained in:
parent
f6af60191b
commit
8ea0c538a0
@ -1,36 +0,0 @@
|
||||
package net.mamoe.mirai.console.scheduler;
|
||||
|
||||
/**
|
||||
* Java开发者的SchedulerTask
|
||||
* 使用kt实现, java的API
|
||||
*/
|
||||
|
||||
/**
|
||||
* PluginScheduler.RepeatTaskReceipt repeatTaskReceipt = this.getScheduler().repeat(() -> {
|
||||
* getLogger().info("I repeat");
|
||||
* },100);
|
||||
*
|
||||
*
|
||||
* this.getScheduler().delay(() -> {
|
||||
* repeatTaskReceipt.setCancelled(true);
|
||||
* },10000);
|
||||
*
|
||||
*
|
||||
* Future<String> future = this.getScheduler().async(() -> {
|
||||
* //do some task
|
||||
* return "success";
|
||||
* });
|
||||
*
|
||||
* try {
|
||||
* getLogger().info(future.get());
|
||||
* } catch (InterruptedException | ExecutionException e) {
|
||||
* e.printStackTrace();
|
||||
* }
|
||||
*/
|
||||
|
||||
public class SchedulerTaskManager {
|
||||
public static SchedulerTaskManagerInstance getInstance(){
|
||||
return SchedulerTaskManagerInstance.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.utils;
|
||||
|
||||
import net.mamoe.mirai.Bot;
|
||||
@ -5,8 +14,8 @@ import net.mamoe.mirai.Bot;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取Bot Manager
|
||||
* Java友好API
|
||||
* 获取 Bot Manager
|
||||
* Java 友好 API
|
||||
*/
|
||||
public class BotManager {
|
||||
|
||||
@ -15,15 +24,15 @@ public class BotManager {
|
||||
return getManagers(bot);
|
||||
}
|
||||
|
||||
public static List<Long> getManagers(Bot bot){
|
||||
public static List<Long> getManagers(Bot bot) {
|
||||
return BotHelperKt.getBotManagers(bot);
|
||||
}
|
||||
|
||||
public static boolean isManager(Bot bot, long target){
|
||||
public static boolean isManager(Bot bot, long target) {
|
||||
return getManagers(bot).contains(target);
|
||||
}
|
||||
|
||||
public static boolean isManager(long botAccount, long target){
|
||||
public static boolean isManager(long botAccount, long target) {
|
||||
return getManagers(botAccount).contains(target);
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
package net.mamoe.mirai.console.utils;
|
||||
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public final class Utils {
|
||||
|
||||
/**
|
||||
* 执行N次 callable
|
||||
* 成功一次就会结束
|
||||
* 否则就会throw
|
||||
*/
|
||||
public static <T> T tryNTimes(@Range(from = 1, to = Integer.MAX_VALUE) int n,
|
||||
Callable<T> callable) throws Exception {
|
||||
Exception last = null;
|
||||
|
||||
while (n-- > 0) {
|
||||
try {
|
||||
return callable.call();
|
||||
} catch (Exception e) {
|
||||
if (last == null) {
|
||||
last = e;
|
||||
} else {
|
||||
try {
|
||||
last.addSuppressed(e);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw last;
|
||||
}
|
||||
}
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:OptIn(MiraiExperimentalAPI::class)
|
||||
|
||||
package net.mamoe.mirai.console.center
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.center
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
|
@ -1,10 +1,19 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
@file:JvmName("CommandManager")
|
||||
|
||||
package net.mamoe.mirai.console.command
|
||||
|
||||
import kotlinx.atomicfu.locks.withLock
|
||||
import net.mamoe.mirai.console.plugins.PluginBase
|
||||
import net.mamoe.mirai.console.plugins.Plugin
|
||||
import net.mamoe.mirai.message.data.Message
|
||||
import net.mamoe.mirai.message.data.MessageChain
|
||||
import net.mamoe.mirai.message.data.SingleMessage
|
||||
@ -13,7 +22,7 @@ sealed class CommandOwner
|
||||
|
||||
object TestCommandOwner : CommandOwner()
|
||||
|
||||
abstract class PluginCommandOwner(plugin: PluginBase) : CommandOwner()
|
||||
abstract class PluginCommandOwner(plugin: Plugin) : CommandOwner()
|
||||
|
||||
// 由前端实现
|
||||
internal abstract class ConsoleCommandOwner : CommandOwner()
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
package net.mamoe.mirai.console.command.description
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package net.mamoe.mirai.console.command.description
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.event
|
||||
|
||||
import net.mamoe.mirai.console.command.Command
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.event
|
||||
|
||||
import net.mamoe.mirai.event.Event
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package net.mamoe.mirai.console.plugins
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
package net.mamoe.mirai.console.plugins
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.plugins.builtin
|
||||
|
||||
import kotlinx.coroutines.*
|
||||
|
@ -6,8 +6,8 @@
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "EXPOSED_SUPER_CLASS")
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "EXPOSED_SUPER_CLASS")
|
||||
|
||||
package net.mamoe.mirai.console.plugins.builtin
|
||||
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.plugins.builtin
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
|
@ -11,7 +11,6 @@ package net.mamoe.mirai.console.utils
|
||||
|
||||
import kotlinx.coroutines.*
|
||||
import net.mamoe.mirai.console.MiraiConsole
|
||||
import net.mamoe.mirai.console.plugins.PluginBase
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
@Suppress("unused")
|
||||
@ -25,30 +24,28 @@ object ConsoleInput {
|
||||
* 如弹出框,或一行字
|
||||
*/
|
||||
suspend fun requestInput(
|
||||
hint:String
|
||||
):String{
|
||||
hint: String
|
||||
): String {
|
||||
return withContext(inputDispatcher) {
|
||||
MiraiConsole.frontEnd.requestInput(hint)
|
||||
}
|
||||
}
|
||||
|
||||
fun requestInputBlocking(hint:String):String = runBlocking { requestInput(hint) }
|
||||
fun requestInputBlocking(hint: String): String = runBlocking { requestInput(hint) }
|
||||
|
||||
/**
|
||||
* asnyc获取
|
||||
*/
|
||||
fun requestInputAsync(
|
||||
pluginBase: PluginBase,
|
||||
scope: CoroutineScope,
|
||||
hint: String
|
||||
):Deferred<String>{
|
||||
return pluginBase.async {
|
||||
): Deferred<String> {
|
||||
return scope.async {
|
||||
requestInput(hint)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun MiraiConsole.requestInput(hint:String):String = requestInput(hint)
|
||||
|
||||
suspend fun PluginBase.requestInputAsync(hint:String):Deferred<String> = requestInputAsync(hint)
|
||||
suspend fun MiraiConsole.requestInput(hint: String): String = requestInput(hint)
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.utils
|
||||
|
||||
import kotlinx.coroutines.*
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "RESULT_CLASS_IN_RETURN_TYPE")
|
||||
|
||||
package net.mamoe.mirai.console.utils
|
||||
|
Loading…
Reference in New Issue
Block a user