Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
87532418
Commit
87532418
authored
Sep 10, 2019
by
Him188moe
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
2038a8fa
1a4cc109
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
20 deletions
+44
-20
README.md
README.md
+32
-17
mirai-core/src/main/java/net/mamoe/mirai/MiraiMain.java
mirai-core/src/main/java/net/mamoe/mirai/MiraiMain.java
+5
-1
mirai-core/src/main/java/net/mamoe/mirai/event/MiraiEventHook.java
...e/src/main/java/net/mamoe/mirai/event/MiraiEventHook.java
+5
-0
mirai-core/src/test/java/ImageOutputTest.java
mirai-core/src/test/java/ImageOutputTest.java
+2
-2
No files found.
README.md
View file @
87532418
...
...
@@ -7,30 +7,45 @@
协议来自网络上开源项目
一切开发旨在学习, 请勿用于非法用途
### 代码结构
Network部分使用 Kotlin 完成(因为kt有对 unsigned byte 的支持).
与插件相关性强(或其他在二次开发中容易接触)的部分尽量使用 Java 完成,
若使用 Kotlin, 我们会通过 Java interface 实现或 javadoc 帮助未接触过 Kotlin 的开发者.
即使你完全不了解 Kotlin, 你也可以正常开发.
### 抢先体验
## 抢先体验
现在你可以使用 Mirai 内置的一些测试qq号体验 Mirai, 但我们现在还不建议你使用自己的 qq 号登录
1.
Clone
2.
Import as Maven project
3.
Run
[
MiraiMain
](
mirai-core/src/main/java/net/mamoe/mirai/MiraiMain.java#L7
)
#### 事件 Hook (Kotlin)

### 事件 Hook (Kotlin)
#### java:
```
MiraiEventHook.onEvent(FriendMessageEvent.class)
.handler(a -> {
if(a.getMessageString().equals("你好"))
a.getQQ().sendMessage("你好!");
})
.mountAlways();
```
#### kotlin:
```
FriendMessageEvent::class.hookAlways{
if(it.message() valueEquals "你好")
it.qq.sendMessage("你好!")
}
```

###
#
图片测试
### 图片测试
**现在可以接受图片消息**
(并解析为消息链):


不过我们还正在努力做发送图片
### TODO
## 代码结构
Network部分使用 Kotlin 完成(因为kt有对 unsigned byte 的支持).
与插件相关性强(或其他在二次开发中容易接触)的部分尽量使用 Java 完成,
若使用 Kotlin, 我们会通过 Java interface 实现或 javadoc 帮助未接触过 Kotlin 的开发者.
即使你完全不了解 Kotlin, 你也可以正常开发.
# TODO
-
[x] 事件(Event)模块
-
[ ] 插件(Plugin)模块
**(Working on)**
-
[x] Network - Touch
...
...
@@ -48,11 +63,11 @@ Network部分使用 Kotlin 完成(因为kt有对 unsigned byte 的支持).
<br>
#
#
使用方法
##
#
要求
# 使用方法
## 要求
-
Java 11 或更高
-
Kotlin 1.3 或更高
##
#
插件开发
## 插件开发
```
text
to be continued
...
...
...
@@ -65,11 +80,11 @@ A JAVA(+Kotlin) powered open-source project under GPL license<br>
It use protocols from
<i>
TIM QQ
</i>
, that is, it won't be affected by the close of
<i>
Smart QQ
</i><br>
The project is all for
<b>
learning proposes
</b>
and still in
<b>
developing stage
</b><br>
#
#
Usage
##
#
Requirements
# Usage
## Requirements
-
Java 11 or higher
-
Kotlin 1.3 or higher
##
#
Plugin Development
## Plugin Development
```
text
to be continued
...
...
...
mirai-core/src/main/java/net/mamoe/mirai/MiraiMain.java
View file @
87532418
package
net.mamoe.mirai
;
import
net.mamoe.mirai.event.MiraiEventHook
;
import
net.mamoe.mirai.event.MiraiEventManager
;
import
net.mamoe.mirai.event.events.qq.FriendMessageEvent
;
/**
* @author Him188moe
*/
...
...
@@ -11,4 +15,4 @@ public final class MiraiMain {
server
=
new
MiraiServer
();
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(()
->
server
.
shutdown
()));
}
}
}
\ No newline at end of file
mirai-core/src/main/java/net/mamoe/mirai/event/MiraiEventHook.java
View file @
87532418
...
...
@@ -95,6 +95,11 @@ public class MiraiEventHook<T extends MiraiEvent> implements Closeable {
MiraiEventManager
.
getInstance
().
registerHook
(
this
);
}
public
void
mountAlways
(){
if
(
this
.
handler
==
null
)
this
.
handler
=
a
->
{};
MiraiEventManager
.
getInstance
().
hookAlways
(
this
);
}
public
void
mountOnce
(){
if
(
this
.
handler
==
null
)
this
.
handler
=
a
->
{};
MiraiEventManager
.
getInstance
().
hookOnce
(
this
);
...
...
mirai-core/src/test/java/ImageOutputTest.java
View file @
87532418
...
...
@@ -7,8 +7,8 @@ import java.io.IOException;
public
class
ImageOutputTest
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
BufferedImage
image
=
ImageIO
.
read
(
new
File
((
System
.
getProperty
(
"user.dir"
)
+
"/
VerificationCode
.png"
).
replace
(
"//"
,
"/"
)));
CharImageConverter
charImageConvertor
=
new
CharImageConverter
(
image
,
10
0
);
BufferedImage
image
=
ImageIO
.
read
(
new
File
((
System
.
getProperty
(
"user.dir"
)
+
"/
mirai
.png"
).
replace
(
"//"
,
"/"
)));
CharImageConverter
charImageConvertor
=
new
CharImageConverter
(
image
,
8
0
);
System
.
out
.
println
(
charImageConvertor
.
call
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment