From da1ef64cfafca8858250b2daf9160c805bedf58f Mon Sep 17 00:00:00 2001 From: Him188 Date: Sat, 14 Sep 2019 00:24:15 +0800 Subject: [PATCH 1/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fcd286c8..1fc4f8c6c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mirai -一个以TIM QQ协议驱动的JAVA(+Kotlin) QQ机器人服务端核心 +一个以TIM QQ协议(非web)驱动的JAVA(+Kotlin) QQ机器人服务端核心 我们坚持免费与开源 项目处于快速开发阶段 From eb64578ff308a38dd81f38e4317ba480cd9a63a6 Mon Sep 17 00:00:00 2001 From: liujiahua123123 Date: Sat, 14 Sep 2019 00:25:04 +0800 Subject: [PATCH 2/3] mirai-api --- mirai-api/pom.xml | 6 ++ .../src/main/java/net/mamoe/mirai/Bot.java | 56 ++++++++++++++++--- .../main/java/net/mamoe/mirai/MiraiAPI.java | 45 +++++++++++++++ .../net/mamoe/mirai/utils/BotAccount.java | 17 ------ .../java/net/mamoe/mirai/MiraiConsole.java | 7 +++ mirai-core/pom.xml | 7 --- .../java/net/mamoe/mirai/MiraiServer.java | 4 +- .../net/mamoe/mirai/utils/BotAccount.java | 13 +++++ 8 files changed, 121 insertions(+), 34 deletions(-) create mode 100644 mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java delete mode 100644 mirai-api/src/main/java/net/mamoe/mirai/utils/BotAccount.java create mode 100644 mirai-console/src/main/java/net/mamoe/mirai/MiraiConsole.java create mode 100644 mirai-core/src/main/java/net/mamoe/mirai/utils/BotAccount.java diff --git a/mirai-api/pom.xml b/mirai-api/pom.xml index 244586af7..116fae742 100644 --- a/mirai-api/pom.xml +++ b/mirai-api/pom.xml @@ -16,6 +16,12 @@ + + net.mamoe + mirai-core + 1.0 + compile + diff --git a/mirai-api/src/main/java/net/mamoe/mirai/Bot.java b/mirai-api/src/main/java/net/mamoe/mirai/Bot.java index 0c60309dc..9f4952b3c 100644 --- a/mirai-api/src/main/java/net/mamoe/mirai/Bot.java +++ b/mirai-api/src/main/java/net/mamoe/mirai/Bot.java @@ -1,15 +1,55 @@ package net.mamoe.mirai; -import net.mamoe.mirai.utils.BotAccount; +import lombok.Getter; -import java.io.Closeable; +import java.util.ArrayList; +import java.util.List; + +public class Bot { + + @Getter + private final long qq; + + public Bot(long qq){ + this.qq = qq; + } + + public String getName(){ + return "Bot"; + } + + public List getOwners(){ + return new ArrayList<>(); + } + + public List getFriends(){ + return new ArrayList<>(); + } + + public void addFriend(){ + + } + + public void deleteFriend(){ + + } + + public void sendMessageTo(long qq, String message){ + + } + + public List getGroups(){ + return new ArrayList<>(); + } + + public void sendGroupMessage(long group, String message){ + + } + + public List getMessageHistory(){ + return new ArrayList<>(); + } -/** - * @author Him188moe - */ -public interface Bot extends Closeable { - BotAccount getAccount(); - // TODO: 2019/9/13 add more } diff --git a/mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java b/mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java new file mode 100644 index 000000000..aed68ca65 --- /dev/null +++ b/mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java @@ -0,0 +1,45 @@ +package net.mamoe.mirai; + +import java.util.ArrayList; +import java.util.List; + +/** + * MiraiAPI provides + * - the status of the Mirai-Core + * - the fundamental bot operations. + * - the plugin status. + * + * It was designed for users, not developers, + * Web-based controller, UI controller or console is depending on Mirai-API + * + * Mirai-API does NOT contains fancy objects, and this means there are less functions it can do compare with Mirai-Core + * + * Again, for extending/developing Mirai, you should refer to Mirai-Core + * for only using , you should refer to Mirai-API + */ +public class MiraiAPI { + public static String getMiraiVersion(){ + return MiraiServer.MIRAI_VERSION; + } + + public static String getQQPortocolVersion(){ + return MiraiServer.QQ_VERSION; + } + + public static boolean isMiraiEnabled(){ + return MiraiServer.getInstance()!=null; + } + + public static List getEnabledPluginList(){ + return new ArrayList<>(); + } + + public static List getEnabledBots(){ + return new ArrayList<>(); + } + + public static Bot getBot(long qq){ + return new Bot(qq); + } + +} diff --git a/mirai-api/src/main/java/net/mamoe/mirai/utils/BotAccount.java b/mirai-api/src/main/java/net/mamoe/mirai/utils/BotAccount.java deleted file mode 100644 index a998a5233..000000000 --- a/mirai-api/src/main/java/net/mamoe/mirai/utils/BotAccount.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.mamoe.mirai.utils; - -import lombok.Data; - -/** - * @author Him188moe - */ -@Data -public final class BotAccount { - public final long qqNumber; - public final String password; - - public BotAccount(long qqNumber, String password) { - this.qqNumber = qqNumber; - this.password = password; - } -} diff --git a/mirai-console/src/main/java/net/mamoe/mirai/MiraiConsole.java b/mirai-console/src/main/java/net/mamoe/mirai/MiraiConsole.java new file mode 100644 index 000000000..3105a8cd6 --- /dev/null +++ b/mirai-console/src/main/java/net/mamoe/mirai/MiraiConsole.java @@ -0,0 +1,7 @@ +package net.mamoe.mirai; + +public class MiraiConsole { + public static void main(String[] args){ + + } +} diff --git a/mirai-core/pom.xml b/mirai-core/pom.xml index bff6e2c4d..4f0afe652 100644 --- a/mirai-core/pom.xml +++ b/mirai-core/pom.xml @@ -30,13 +30,6 @@ compile - - net.mamoe - mirai-api - 1.0 - compile - - com.google.protobuf protobuf-java diff --git a/mirai-core/src/main/java/net/mamoe/mirai/MiraiServer.java b/mirai-core/src/main/java/net/mamoe/mirai/MiraiServer.java index b722713c2..e28a84b0d 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/MiraiServer.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/MiraiServer.java @@ -35,9 +35,9 @@ public final class MiraiServer { return instance; } - private final static String MIRAI_VERSION = "1.0.0"; + public final static String MIRAI_VERSION = "1.0.0"; - private final static String QQ_VERSION = "4.9.0"; + public final static String QQ_VERSION = "4.9.0"; @Getter //is running under UNIX diff --git a/mirai-core/src/main/java/net/mamoe/mirai/utils/BotAccount.java b/mirai-core/src/main/java/net/mamoe/mirai/utils/BotAccount.java new file mode 100644 index 000000000..ef2dcefa3 --- /dev/null +++ b/mirai-core/src/main/java/net/mamoe/mirai/utils/BotAccount.java @@ -0,0 +1,13 @@ +package net.mamoe.mirai.utils; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class BotAccount { + + public final long qqNumber; + private final String password; + +} From deeb8fa342ee6e99b1c7db31af9997a6bb1f636e Mon Sep 17 00:00:00 2001 From: liujiahua123123 Date: Sat, 14 Sep 2019 00:33:33 +0800 Subject: [PATCH 3/3] miraiAPI --- mirai-api/src/main/java/net/mamoe/mirai/Bot.java | 8 ++++++++ .../src/main/java/net/mamoe/mirai/MiraiAPI.java | 14 ++++++++++++++ .../src/main/java/net/mamoe/mirai/MiraiMain.java | 3 +++ 3 files changed, 25 insertions(+) diff --git a/mirai-api/src/main/java/net/mamoe/mirai/Bot.java b/mirai-api/src/main/java/net/mamoe/mirai/Bot.java index 9f4952b3c..5126fbd75 100644 --- a/mirai-api/src/main/java/net/mamoe/mirai/Bot.java +++ b/mirai-api/src/main/java/net/mamoe/mirai/Bot.java @@ -42,6 +42,14 @@ public class Bot { return new ArrayList<>(); } + public void addGroup(){ + + } + + public void quitGroup(){ + + } + public void sendGroupMessage(long group, String message){ } diff --git a/mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java b/mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java index aed68ca65..c77d268b6 100644 --- a/mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java +++ b/mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java @@ -18,6 +18,20 @@ import java.util.List; * for only using , you should refer to Mirai-API */ public class MiraiAPI { + + public static void startMirai(String[] args){ + MiraiMain.main(args); + } + + public static void closeMirai(){ + MiraiServer.getInstance().shutdown(); + } + + public static void restartMirai(String[] args){ + MiraiServer.getInstance().shutdown(); + MiraiMain.main(args); + } + public static String getMiraiVersion(){ return MiraiServer.MIRAI_VERSION; } diff --git a/mirai-core/src/main/java/net/mamoe/mirai/MiraiMain.java b/mirai-core/src/main/java/net/mamoe/mirai/MiraiMain.java index 858f581aa..17a003ab8 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/MiraiMain.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/MiraiMain.java @@ -1,10 +1,13 @@ package net.mamoe.mirai; +import lombok.Getter; + /** * @author NaturalHG */ public final class MiraiMain { + @Getter private static MiraiServer server; public static void main(String[] args) {