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
3a458322
Commit
3a458322
authored
Feb 20, 2020
by
ryoii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http event with bug
parent
61838a0e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
10 deletions
+45
-10
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/Session.kt
...-http/src/main/kotlin/net/mamoe/mirai/api/http/Session.kt
+4
-4
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/BotEventDTO.kt
...otlin/net/mamoe/mirai/api/http/data/common/BotEventDTO.kt
+0
-0
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/MessageDTO.kt
...kotlin/net/mamoe/mirai/api/http/data/common/MessageDTO.kt
+1
-1
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt
...ain/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt
+4
-4
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/util/Json.kt
...ttp/src/main/kotlin/net/mamoe/mirai/api/http/util/Json.kt
+36
-1
No files found.
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/Session.kt
View file @
3a458322
...
@@ -13,6 +13,8 @@ import kotlinx.coroutines.*
...
@@ -13,6 +13,8 @@ import kotlinx.coroutines.*
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.api.http.queue.MessageQueue
import
net.mamoe.mirai.api.http.queue.MessageQueue
import
net.mamoe.mirai.event.Listener
import
net.mamoe.mirai.event.Listener
import
net.mamoe.mirai.event.events.BotEvent
import
net.mamoe.mirai.event.subscribeAlways
import
net.mamoe.mirai.event.subscribeMessages
import
net.mamoe.mirai.event.subscribeMessages
import
net.mamoe.mirai.message.MessagePacket
import
net.mamoe.mirai.message.MessagePacket
import
kotlin.coroutines.CoroutineContext
import
kotlin.coroutines.CoroutineContext
...
@@ -102,12 +104,10 @@ class TempSession internal constructor(coroutineContext: CoroutineContext) : Ses
...
@@ -102,12 +104,10 @@ class TempSession internal constructor(coroutineContext: CoroutineContext) : Ses
class
AuthedSession
internal
constructor
(
val
bot
:
Bot
,
coroutineContext
:
CoroutineContext
)
:
Session
(
coroutineContext
)
{
class
AuthedSession
internal
constructor
(
val
bot
:
Bot
,
coroutineContext
:
CoroutineContext
)
:
Session
(
coroutineContext
)
{
val
messageQueue
=
MessageQueue
()
val
messageQueue
=
MessageQueue
()
private
val
_listener
:
Listener
<
MessagePacket
<
*
,
*
>
>
private
val
_listener
:
Listener
<
BotEvent
>
init
{
init
{
bot
.
subscribeMessages
{
_listener
=
bot
.
subscribeAlways
{
this
.
run
(
messageQueue
::
add
)
}
_listener
=
always
{
this
.
run
(
messageQueue
::
add
)
}
// this aka messagePacket
}
}
}
override
fun
close
()
{
override
fun
close
()
{
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/EventDTO.kt
→
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/
Bot
EventDTO.kt
View file @
3a458322
File moved
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/MessageDTO.kt
View file @
3a458322
...
@@ -66,7 +66,7 @@ data class UnknownMessageDTO(val text: String) : MessageDTO()
...
@@ -66,7 +66,7 @@ data class UnknownMessageDTO(val text: String) : MessageDTO()
* Abstract Class
* Abstract Class
* */
* */
@Serializable
@Serializable
sealed
class
MessagePacketDTO
:
DTO
{
sealed
class
MessagePacketDTO
:
EventDTO
()
{
lateinit
var
messageChain
:
MessageChainDTO
lateinit
var
messageChain
:
MessageChainDTO
}
}
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt
View file @
3a458322
...
@@ -9,20 +9,20 @@
...
@@ -9,20 +9,20 @@
package
net.mamoe.mirai.api.http.queue
package
net.mamoe.mirai.api.http.queue
import
net.mamoe.mirai.event.events.BotEvent
import
net.mamoe.mirai.message.GroupMessage
import
net.mamoe.mirai.message.GroupMessage
import
net.mamoe.mirai.message.MessagePacket
import
net.mamoe.mirai.message.data.MessageSource
import
net.mamoe.mirai.message.data.MessageSource
import
java.util.concurrent.ConcurrentHashMap
import
java.util.concurrent.ConcurrentHashMap
import
java.util.concurrent.ConcurrentLinkedDeque
import
java.util.concurrent.ConcurrentLinkedDeque
class
MessageQueue
:
ConcurrentLinkedDeque
<
MessagePacket
<
*
,
*
>
>()
{
class
MessageQueue
:
ConcurrentLinkedDeque
<
BotEvent
>()
{
val
quoteCache
=
ConcurrentHashMap
<
Long
,
GroupMessage
>()
val
quoteCache
=
ConcurrentHashMap
<
Long
,
GroupMessage
>()
fun
fetch
(
size
:
Int
):
List
<
MessagePacket
<
*
,
*
>
>
{
fun
fetch
(
size
:
Int
):
List
<
BotEvent
>
{
var
count
=
size
var
count
=
size
quoteCache
.
clear
()
quoteCache
.
clear
()
val
ret
=
ArrayList
<
MessagePacket
<
*
,
*
>
>(
count
)
val
ret
=
ArrayList
<
BotEvent
>(
count
)
while
(!
this
.
isEmpty
()
&&
count--
>
0
)
{
while
(!
this
.
isEmpty
()
&&
count--
>
0
)
{
val
packet
=
pop
()
val
packet
=
pop
()
ret
.
add
(
packet
)
ret
.
add
(
packet
)
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/util/Json.kt
View file @
3a458322
...
@@ -13,7 +13,6 @@ import kotlinx.serialization.*
...
@@ -13,7 +13,6 @@ import kotlinx.serialization.*
import
kotlinx.serialization.json.Json
import
kotlinx.serialization.json.Json
import
kotlinx.serialization.modules.SerializersModule
import
kotlinx.serialization.modules.SerializersModule
import
net.mamoe.mirai.api.http.data.common.*
import
net.mamoe.mirai.api.http.data.common.*
import
net.mamoe.mirai.message.data.MessageSource
// 解析失败时直接返回null,由路由判断响应400状态
// 解析失败时直接返回null,由路由判断响应400状态
@UseExperimental
(
ImplicitReflectionSerializer
::
class
)
@UseExperimental
(
ImplicitReflectionSerializer
::
class
)
...
@@ -45,11 +44,47 @@ else MiraiJson.json.stringify(serializer, this)
...
@@ -45,11 +44,47 @@ else MiraiJson.json.stringify(serializer, this)
*/
*/
object
MiraiJson
{
object
MiraiJson
{
val
json
=
Json
(
context
=
SerializersModule
{
val
json
=
Json
(
context
=
SerializersModule
{
polymorphic
(
EventDTO
.
serializer
())
{
BotEventDTO
::
class
with
BotEventDTO
.
serializer
()
MessagePacketDTO
::
class
with
MessagePacketDTO
.
serializer
()
}
polymorphic
(
MessagePacketDTO
.
serializer
())
{
polymorphic
(
MessagePacketDTO
.
serializer
())
{
GroupMessagePacketDTO
::
class
with
GroupMessagePacketDTO
.
serializer
()
GroupMessagePacketDTO
::
class
with
GroupMessagePacketDTO
.
serializer
()
FriendMessagePacketDTO
::
class
with
FriendMessagePacketDTO
.
serializer
()
FriendMessagePacketDTO
::
class
with
FriendMessagePacketDTO
.
serializer
()
UnKnownMessagePacketDTO
::
class
with
UnKnownMessagePacketDTO
.
serializer
()
UnKnownMessagePacketDTO
::
class
with
UnKnownMessagePacketDTO
.
serializer
()
}
}
// Bot Event Polymorphic
polymorphic
(
BotEventDTO
.
serializer
())
{
BotOnlineEventDTO
::
class
with
BotOnlineEventDTO
.
serializer
()
BotOfflineEventActiveDTO
::
class
with
BotOfflineEventActiveDTO
.
serializer
()
BotOfflineEventForceDTO
::
class
with
BotOfflineEventForceDTO
.
serializer
()
BotOfflineEventDroppedDTO
::
class
with
BotOfflineEventDroppedDTO
.
serializer
()
BotReloginEventDTO
::
class
with
BotReloginEventDTO
.
serializer
()
BotGroupPermissionChangeEventDTO
::
class
with
BotGroupPermissionChangeEventDTO
.
serializer
()
BotMuteEventDTO
::
class
with
BotMuteEventDTO
.
serializer
()
BotUnmuteEventDTO
::
class
with
BotUnmuteEventDTO
.
serializer
()
BotJoinGroupEventDTO
::
class
with
BotJoinGroupEventDTO
.
serializer
()
GroupNameChangeEventDTO
::
class
with
GroupNameChangeEventDTO
.
serializer
()
GroupEntranceAnnouncementChangeEventDTO
::
class
with
GroupEntranceAnnouncementChangeEventDTO
.
serializer
()
GroupMuteAllEventDTO
::
class
with
GroupMuteAllEventDTO
.
serializer
()
GroupAllowAnonymousChatEventDTO
::
class
with
GroupAllowAnonymousChatEventDTO
.
serializer
()
GroupAllowConfessTalkEventDTO
::
class
with
GroupAllowConfessTalkEventDTO
.
serializer
()
GroupAllowMemberInviteEventDTO
::
class
with
GroupAllowMemberInviteEventDTO
.
serializer
()
MemberJoinEventDTO
::
class
with
MemberJoinEventDTO
.
serializer
()
MemberLeaveEventKickDTO
::
class
with
MemberLeaveEventKickDTO
.
serializer
()
MemberLeaveEventQuitDTO
::
class
with
MemberLeaveEventQuitDTO
.
serializer
()
MemberCardChangeEventDTO
::
class
with
MemberCardChangeEventDTO
.
serializer
()
MemberSpecialTitleChangeEventDTO
::
class
with
MemberSpecialTitleChangeEventDTO
.
serializer
()
MemberPermissionChangeEventDTO
::
class
with
MemberPermissionChangeEventDTO
.
serializer
()
MemberMuteEventDTO
::
class
with
MemberMuteEventDTO
.
serializer
()
MemberUnmuteEventDTO
::
class
with
MemberUnmuteEventDTO
.
serializer
()
}
// Message Polymorphic
polymorphic
(
MessageDTO
.
serializer
())
{
polymorphic
(
MessageDTO
.
serializer
())
{
MessageSourceDTO
::
class
with
MessageSourceDTO
.
serializer
()
MessageSourceDTO
::
class
with
MessageSourceDTO
.
serializer
()
AtDTO
::
class
with
AtDTO
.
serializer
()
AtDTO
::
class
with
AtDTO
.
serializer
()
...
...
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