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机器人服务端核心 我们坚持免费与开源 项目处于快速开发阶段 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..5126fbd75 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,63 @@ 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 addGroup(){ + + } + + public void quitGroup(){ + + } + + 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..c77d268b6 --- /dev/null +++ b/mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java @@ -0,0 +1,59 @@ +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 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; + } + + 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 f9b50986f..1d8de0d46 100644 --- a/mirai-core/pom.xml +++ b/mirai-core/pom.xml @@ -39,13 +39,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/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) { 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 be790361f..f8ab4ec0f 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; + +}