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
e9ad97ee
Commit
e9ad97ee
authored
Oct 11, 2019
by
Him188
Committed by
GitHub
Oct 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update README.md
parent
8e323644
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
11 deletions
+46
-11
README.md
README.md
+46
-11
No files found.
README.md
View file @
e9ad97ee
# Mirai
# Mirai
[

](http://hits.dwyl.io/him188/mamoe/mirai)
[

](http://hits.dwyl.io/him188/mamoe/mirai)
一个以
<b>
TIM QQ协议(非web)
</b>
驱动的QQ机器人服务端核心
一个以
**TIM QQ协议(非web)**
驱动的QQ机器人服务端核心
采用服务端-插件模式运行,同时提供独立的
协议层
库
采用服务端-插件模式运行,同时提供独立的
核心
库
项目
的所有模块均开源
Mirai
的所有模块均开源
项目处于开发阶段,学生无法每日大量更新。
项目处于开发阶段,学生无法每日大量更新。
项目还有很多未完善的地方, 欢迎任何的代码贡献, 或是 issue.
项目还有很多未完善的地方, 欢迎任何的代码贡献, 或是 issue.
...
@@ -19,20 +19,54 @@
...
@@ -19,20 +19,54 @@
目前还没有写构建,请使用 IDE 运行单个 main 函数。
目前还没有写构建,请使用 IDE 运行单个 main 函数。
1.
Clone
1.
Clone
2.
Import as Gradle project
2.
Import as Gradle project
3.
Run demo
[
Demo 1 Main
](
mirai-demos/mirai-demo-1/src/main/java/demo1/Main.kt#L22
)
3.
Run demo
main
[
Demo 1 Main
](
mirai-demos/mirai-demo-1/src/main/java/demo1/Main.kt#L22
)
### 事件
Hook
### 事件
#### Kotlin:
#### Kotlin:
这里只演示进行不终止地监听。
##### Top-level reified
多数情况下这是最好的方式。
```
kotlin
```
kotlin
FriendMessageEvent
.
subscribeAlways
{
inline
fun
<
reified
E
:
Event
>
subscribeAlways
(
handler
:
E
->
Unit
)
subscribeAlways
<
FriendMessageEvent
>{
//it: MessageChain
}
```
##### DSL
查看更多:
[
ListenerBuilder
](
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/event/Subscribers.kt#L69
)
```
kotlin
inline
fun
<
reified
E
:
Event
>
subscribeAll
(
builder
:
ListenerBuilder
.()
->
Unit
)
subscribe
<
FriendMessageEvent
>{
always
{
//it: MessageChain
//coroutineContext: EventScope.coroutineContext
}
//可同时开始多个监听。
always
{
//it: MessageChain
//coroutineContext: EventScope.coroutineContext
}
}
```
##### KClass extension
更推荐使用 Top-level reified
```
kotlin
fun
<
E
:
Event
>
KClass
<
E
>.
subscribeAlways
(
listener
:
suspend
(
E
)
->
Unit
)
FriendMessageEvent
::
class
.
subscribeAlways
{
if
(
it
.
message
eq
"你好"
)
if
(
it
.
message
eq
"你好"
)
it
.
reply
(
"你好!"
)
it
.
reply
(
"你好!"
)
}
}
```
```


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




...
@@ -41,7 +75,7 @@ FriendMessageEvent.subscribeAlways{
...
@@ -41,7 +75,7 @@ FriendMessageEvent.subscribeAlways{
# TODO
# TODO
-
[x] 事件(Event)模块
-
[x] 事件(Event)模块
-
[ ] 插件(Plugin)模块
**(Working on)**
-
[ ] 插件(Plugin)模块
-
[x] Network - Touch
-
[x] Network - Touch
-
[X] Network - Login
-
[X] Network - Login
-
[X] Network - Session
-
[X] Network - Session
...
@@ -52,7 +86,7 @@ FriendMessageEvent.subscribeAlways{
...
@@ -52,7 +86,7 @@ FriendMessageEvent.subscribeAlways{
-
[ ] Bot - Friend/group list
-
[ ] Bot - Friend/group list
-
[ ] Bot - Actions(joining group, adding friend, etc.)
-
[ ] Bot - Actions(joining group, adding friend, etc.)
-
[x] Message Section
-
[x] Message Section
-
[ ] Image uploading
**(Working on)**
-
[ ] Image uploading
-
[ ] Contact
-
[ ] Contact
-
[ ] UI
-
[ ] UI
-
[ ] Console
-
[ ] Console
...
@@ -61,8 +95,9 @@ FriendMessageEvent.subscribeAlways{
...
@@ -61,8 +95,9 @@ FriendMessageEvent.subscribeAlways{
# 使用方法
# 使用方法
## 要求
## 要求
-
Java 11 或更高
-
Kotlin 1.3+
-
Kotlin 1.3 或更高
### JVM
-
Java 11
## 插件开发
## 插件开发
```
text
```
text
to be continued
to be continued
...
...
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