# MiraiJavaEasy **Repository Path**: fanwen-magician/mirai-java-easy ## Basic Information - **Project Name**: MiraiJavaEasy - **Description**: 对于mirai框架的简单java分装,可以更方便的注册用户,创建并挂载事件等 - **Primary Language**: Java - **License**: AGPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 0 - **Created**: 2021-03-31 - **Last Updated**: 2023-01-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MiraiJavaEasy
### 介绍 MiraiJavaEasy 是对 [mirai](https://github.com/mamoe/mirai) 框架的简单Java封装。
目的是让Java开发者更方便的注册Bot,创建简单的事件。而不用去思考复杂的Kotlin代码 ### 特点 1. 轻量级
MiraiJavaEasy 只使用了mirai-core-jvm和mirai-login-solver-selenium这两个依赖。 较少的依赖可以使其适应更多的开发环境,给予开发者更多选择。
且相对于其他大型框架,MiraiJavaEasy的学习成本较少,更适合初级Java开发者。 2. 面向接口编程
MiraiJavaEasy 使用了面向接口编程的编程思路,开发者只需要继承指定接口或抽象类,即可使用。 ### 声明 #### 一切开发旨在学习,请勿用于非法用途 * MiraiJavaEasy 是完全免费且开放源代码的框架,仅供学习和娱乐用途使用
* MiraiJavaEasy 不会通过任何方式强制收取费用,或对使用者提出物质条件
#### 许可证 ```text Copyright (C) 2020-2021 FangwenMagician This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . ``` MiraiJavaEasy 采用 AGPLv3 协议开源。
请注意,由于种种原因,开发者可能在任何时间停止更新删除项目
### 安装教程 1. 在maven中导入以下包
```xml top.miraijavaeasy MiraiJavaEasy 2.1.0 ``` 你也可以去 [target目录](/target)下载jar包加载。但不推荐这样做。
注:MiraiJavaEasy会自动引入mirai-core-jvm和mirai-login-solver-selenium这两个依赖,你无需再手动引入!
2. 配置maven仓库(2.0.0以上版本不需要)
```xml jcenter https://jcenter.bintray.com/ ``` ### 快速上手 创建MiraiConfiguration对象并且配置, 之后使用匿名类创建一个基于MiraiJavaEasyGroupMessageEvent抽象类的对象,并且挂载到Bot上。
```java import net.mamoe.mirai.Bot; import net.mamoe.mirai.event.Listener; import net.mamoe.mirai.event.events.FriendMessageEvent; import net.mamoe.mirai.event.events.GroupMessageEvent; import net.mamoe.mirai.message.data.MessageUtils; import top.MiraiJavaEasy.Event.MiraiJavaEasyFriendMessageEvent; import top.MiraiJavaEasy.Event.MiraiJavaEasyGroupMessageEvent; import top.MiraiJavaEasy.ListenerBuild; import top.MiraiJavaEasy.MiraiConfiguration; import java.io.File; import java.util.Scanner; public class Test1 { public static void main(String[] args) { //创建Bot对象 MiraiConfiguration miraiConfiguration = new MiraiConfiguration(); miraiConfiguration.setQQNumber(QQ号); miraiConfiguration.setQQPassword(密码); miraiConfiguration.setDeviceInformation("登入设备信息.json"); Bot bot = miraiConfiguration.LoadAndLogin(); //创建并挂载单个事件 Listener listener = new ListenerBuild(bot).toListener(new MiraiJavaEasyGroupMessageEvent() { @Override public void Start(GroupMessageEvent MiraiEvent) throws Exception { MiraiEvent.getGroup().sendMessage(MessageUtils.newChain() .plus("群聊——Bot测试中,你刚刚发送了:") .plus(MiraiEvent.getMessage())); } }); Listener listener2 = new ListenerBuild(bot).toListener(new MiraiJavaEasyFriendMessageEvent() { @Override public void Start(FriendMessageEvent MiraiEvent) throws Exception { MiraiEvent.getFriend().sendMessage(MessageUtils.newChain() .plus("私聊——Bot测试中,你刚刚发送了:") .plus(MiraiEvent.getMessage())); } }); while (true) { String input = new Scanner(System.in).next(); //退出程序 if ("exit".equals(input) || "quit".equals(input)) { bot.close(); break; } //关闭事件 if ("c".equals(input)) { listener.complete(); listener2.complete(); } } } } ``` ### 文档 在文档中,我会详细介绍MiraiJavaEasy框架的各种使用方式,按照步骤来,总会明白的:) 1. [创建Bot](/docs/Bot.md) 2. [创建事件](/docs/Event.md) 3. [挂载事件](/docs/ListenerBuild.md)