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
d9692c3b
Commit
d9692c3b
authored
Feb 20, 2020
by
ryoii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ignore IgnoreEventDTO from fetch list
parent
47601918
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt
...ain/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt
+16
-7
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/SendMessageRouteModule.kt
.../net/mamoe/mirai/api/http/route/SendMessageRouteModule.kt
+1
-2
No files found.
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt
View file @
d9692c3b
...
@@ -9,6 +9,9 @@
...
@@ -9,6 +9,9 @@
package
net.mamoe.mirai.api.http.queue
package
net.mamoe.mirai.api.http.queue
import
net.mamoe.mirai.api.http.data.common.EventDTO
import
net.mamoe.mirai.api.http.data.common.IgnoreEventDTO
import
net.mamoe.mirai.api.http.data.common.toDTO
import
net.mamoe.mirai.event.events.BotEvent
import
net.mamoe.mirai.event.events.BotEvent
import
net.mamoe.mirai.message.GroupMessage
import
net.mamoe.mirai.message.GroupMessage
import
net.mamoe.mirai.message.data.MessageSource
import
net.mamoe.mirai.message.data.MessageSource
...
@@ -19,16 +22,22 @@ class MessageQueue : ConcurrentLinkedDeque<BotEvent>() {
...
@@ -19,16 +22,22 @@ class MessageQueue : ConcurrentLinkedDeque<BotEvent>() {
val
quoteCache
=
ConcurrentHashMap
<
Long
,
GroupMessage
>()
val
quoteCache
=
ConcurrentHashMap
<
Long
,
GroupMessage
>()
fun
fetch
(
size
:
Int
):
List
<
BotEvent
>
{
fun
fetch
(
size
:
Int
):
List
<
EventDTO
>
{
var
count
=
size
var
count
=
size
quoteCache
.
clear
()
quoteCache
.
clear
()
val
ret
=
ArrayList
<
BotEvent
>(
count
)
val
ret
=
ArrayList
<
EventDTO
>(
count
)
while
(!
this
.
isEmpty
()
&&
count--
>
0
)
{
while
(!
this
.
isEmpty
()
&&
count
>
0
)
{
val
packet
=
pop
()
val
event
=
pop
()
ret
.
add
(
packet
)
if
(
packet
is
GroupMessage
)
{
event
.
toDTO
().
also
{
addCache
(
packet
)
if
(
it
!=
IgnoreEventDTO
)
{
ret
.
add
(
it
)
count--
}
}
if
(
event
is
GroupMessage
)
{
addCache
(
event
)
}
}
}
}
return
ret
return
ret
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/SendMessageRouteModule.kt
View file @
d9692c3b
...
@@ -37,9 +37,8 @@ fun Application.messageModule() {
...
@@ -37,9 +37,8 @@ fun Application.messageModule() {
miraiGet
(
"/fetchMessage"
)
{
miraiGet
(
"/fetchMessage"
)
{
val
count
:
Int
=
paramOrNull
(
"count"
)
val
count
:
Int
=
paramOrNull
(
"count"
)
val
fetch
=
it
.
messageQueue
.
fetch
(
count
)
val
fetch
=
it
.
messageQueue
.
fetch
(
count
)
val
ls
=
Array
(
fetch
.
size
)
{
index
->
fetch
[
index
].
toDTO
()
}
call
.
respondJson
(
ls
.
toList
()
.
toJson
())
call
.
respondJson
(
fetch
.
toJson
())
}
}
miraiVerify
<
SendDTO
>(
"/sendFriendMessage"
)
{
miraiVerify
<
SendDTO
>(
"/sendFriendMessage"
)
{
...
...
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