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
aac8b08f
Commit
aac8b08f
authored
Sep 08, 2019
by
Him188moe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated message
parent
3adfed6e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
14 deletions
+29
-14
.README_images/68f8fec9.png
.README_images/68f8fec9.png
+0
-0
.github/A}YWVE860U(%YQD$R1GB1[P.png
.github/A}YWVE860U(%YQD$R1GB1[P.png
+0
-0
.github/J]CE)IK4BU08(EO~UVLJ{[F.png
.github/J]CE)IK4BU08(EO~UVLJ{[F.png
+0
-0
README.md
README.md
+17
-11
mirai-core/src/main/java/net/mamoe/mirai/event/MiraiEventManagerKt.kt
...rc/main/java/net/mamoe/mirai/event/MiraiEventManagerKt.kt
+1
-1
mirai-core/src/main/java/net/mamoe/mirai/network/RobotNetworkHandler.kt
.../main/java/net/mamoe/mirai/network/RobotNetworkHandler.kt
+11
-2
No files found.
.README_images/68f8fec9.png
0 → 100644
View file @
aac8b08f
5.41 KB
.github/A}YWVE860U(%YQD$R1GB1[P.png
0 → 100644
View file @
aac8b08f
4.32 KB
.github/J]CE)IK4BU08(EO~UVLJ{[F.png
0 → 100644
View file @
aac8b08f
7.29 KB
README.md
View file @
aac8b08f
...
...
@@ -5,13 +5,7 @@
项目处于快速开发阶段
协议来自网络上开源项目
一切开发旨在学习, 请勿用于非法用途
<br>
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>
一切开发旨在学习, 请勿用于非法用途
### 代码结构
Network部分使用 Kotlin 完成(因为kt有对 unsigned byte 的支持).
...
...
@@ -20,15 +14,21 @@ Network部分使用 Kotlin 完成(因为kt有对 unsigned byte 的支持).
即使你完全不了解 Kotlin, 你也可以正常开发.
### 抢先体验
现在你可以使用 Mirai 内置的一些测试qq号体验 Mirai
.
现在你可以使用 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)


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


不过我们还正在努力做发送图片
### TODO
-
[x] 事件(Event)模块
...
...
@@ -59,6 +59,12 @@ Hook 一个事件(Kotlin):
```
<br>
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
-
Java 11 or higher
...
...
mirai-core/src/main/java/net/mamoe/mirai/event/MiraiEventManagerKt.kt
View file @
aac8b08f
...
...
@@ -62,6 +62,6 @@ fun <C : KClass<E>, E : MiraiEvent> C.hookWhile(hook: (E) -> Boolean) {
private
class
MiraiEventHookSimple
<
E
:
MiraiEvent
>(
clazz
:
Class
<
E
>,
val
hook
:
(
E
)
->
Boolean
)
:
MiraiEventHook
<
E
>(
clazz
)
{
override
fun
accept
(
event
:
MiraiEvent
?):
Boolean
{
@Suppress
(
"UNCHECKED_CAST"
)
return
hook
.
invoke
(
event
as
E
)
return
!
hook
.
invoke
(
event
as
E
)
}
}
\ No newline at end of file
mirai-core/src/main/java/net/mamoe/mirai/network/RobotNetworkHandler.kt
View file @
aac8b08f
...
...
@@ -12,7 +12,6 @@ import net.mamoe.mirai.event.events.network.PacketSentEvent
import
net.mamoe.mirai.event.events.network.ServerPacketReceivedEvent
import
net.mamoe.mirai.event.events.qq.FriendMessageEvent
import
net.mamoe.mirai.event.events.robot.RobotLoginSucceedEvent
import
net.mamoe.mirai.event.hookAlways
import
net.mamoe.mirai.event.hookWhile
import
net.mamoe.mirai.message.Message
import
net.mamoe.mirai.message.defaults.MessageChain
...
...
@@ -261,6 +260,10 @@ class RobotNetworkHandler(private val robot: Robot) : Closeable {
this
.
loginFuture
=
null
}
}
fun
isClosed
():
Boolean
{
return
this
.
socket
?.
isClosed
?:
true
}
}
...
...
@@ -485,12 +488,18 @@ class RobotNetworkHandler(private val robot: Robot) : Closeable {
internal
var
ignoreMessage
:
Boolean
=
false
init
{
FriendMessageEvent
::
class
.
hookAlways
{
//todo for test
FriendMessageEvent
::
class
.
hookWhile
{
if
(
socketHandler
.
isClosed
())
{
return
@
hookWhile
false
}
if
(
it
.
message
()
valueEquals
"你好"
)
{
it
.
qq
.
sendMessage
(
"你好!"
)
}
else
if
(
it
.
message
().
toString
().
startsWith
(
"复读"
))
{
it
.
qq
.
sendMessage
(
it
.
message
())
}
return
@
hookWhile
true
}
}
...
...
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