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
7842ce31
Commit
7842ce31
authored
Nov 02, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update image API
parent
4ddfc0b5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
7 deletions
+16
-7
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/internal/MessageDataInternal.kt
...n/net.mamoe.mirai/message/internal/MessageDataInternal.kt
+2
-2
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/GentleImage.kt
...o-gentleman/src/main/kotlin/demo/gentleman/GentleImage.kt
+12
-2
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Gentleman.kt
...emo-gentleman/src/main/kotlin/demo/gentleman/Gentleman.kt
+0
-1
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
...rai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
+2
-2
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/internal/MessageDataInternal.kt
View file @
7842ce31
...
@@ -23,10 +23,10 @@ internal fun IoBuffer.parsePlainText(): PlainText {
...
@@ -23,10 +23,10 @@ internal fun IoBuffer.parsePlainText(): PlainText {
}
}
internal
fun
IoBuffer
.
parseLongText0x19
():
PlainText
{
internal
fun
IoBuffer
.
parseLongText0x19
():
PlainText
{
//
01 00 59 AA 02 56 30 01 3A 40 6E 35 46 4F 62 68 75 4B 6F 65 31 4E 63 45 41 6B 77 4B 51 5A 5A 4C 47 54 57 43 68 30 4B 56 7A 57 44 38 67 58 70 37 62 77 6A 67 51 69 66 66 53 4A 63 4F 69 78 4F 75 37 36 49 49 4F 37 48 32 55 63 9A 01 0F 80 01 01 C8 01 00 F0 01 00 F8 01 00 90 02 00 14 01 75 01 01 6B 01 78 9C CD 92 BB 4E C3 30 14 86 77 9E C2 32 73 DA A4 21 24 48 4E AA F4 06 A5 B4 51 55 A0 A8 0B 4A 5D 27 35 E4 82 72 69 4B B7 6E 08 06 C4 C0 06 42 48 30 20 21 60 62 EB E3 34 F4 31 70 4A 11 23 23 FC 96 2C F9 D8 BF CF F1 77 8C F2 23 D7 01 03 12 84 D4 F7 54 28 64 78 08 88 87 FD 1E F5 6C 15 C6 91 C5 29 30 AF AD 00 26 E4 86 36 E8 06 94 58 2A CC FC 73 41 E0 1E 5A D4 21 0D D3 25 2A 2C 55 0A 1B D2 BA 5E E0 24 91 D7 B9 B5 72 41 E1 74 B9 5C E0 78 25 27 8B 92 28 14 45 45 FF 76 B4 E8 98 39 18 05 13 47 0B 24 03 4A 86 F5 D8 89 68 3D B4 21 B0 1C 93 71 11 21 08 49 30 A0 98 54 4B 6C 25 A5 E6 80 84 B4 A7 42 4F AA 18 DD 7E 5C F3 89 D0 C0 65 FD 78 58 6B 76 3A 3B 9B BB ED 62 9F AF ED 8F DB 25 C5 3E 38 91 BB C3 23 BB 49 2D AB B5 8D 0D 3A 32 62 79 BD 5A 35 E4 AD DC 1E 86 40 03 88 46 C4 05 8E 79 EA C7 11 EB 09 64 91 88 46 0E D1 C0 5F 73 FD 4D 00 65 97 95 02 D4 0F 34 94 65 D3 B2 78 80 7D C7 0F 54 B8 AA F0 E9 60 8F 4A EE 1E 3F 6E 2E 84 E4 F6 7E 3E 7D 9E 5D 5E 25 EF 67 C9 E4 15 FC DC 81 B2 29 08 0D 85 7E 1C 60 02 BC 45 33 E7 93 F3 D9 C3 D3 FC E5 6D 36 BD 86 2C C3 D7 66 7A 98 FD 4F ED 13 9B C7 C1 78 02 00 04 00 00 00 23 0E 00 07 01 00 04 00 00 00 09
//
AA 02 33 50 00 60 00 68 00 9A 01 2A 08 0A 20 C1 50 78 A7 C0 04 80 01 01 C8 01 00 F0 01 00 F8 01 00 90 02 00 98 03 00 A0 03 00 B0 03 00 C0 03 00 D0 03 00 E8 03 00
discardExact
(
1
)
//0x01
discardExact
(
1
)
//0x01
val
raw
=
readLVByteArray
()
val
raw
=
readLVByteArray
()
//
TODO 这
应该是手机发送时的字体或气泡之类的
//
应该是手机发送时的字体或气泡之类的
println
(
"parseLongText0x19.raw=${raw.toUHexString()}"
)
println
(
"parseLongText0x19.raw=${raw.toUHexString()}"
)
return
PlainText
(
""
)
return
PlainText
(
""
)
}
}
...
...
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/GentleImage.kt
View file @
7842ce31
package
demo.gentleman
package
demo.gentleman
import
com.alibaba.fastjson.JSON
import
kotlinx.coroutines.*
import
kotlinx.coroutines.*
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.message.Image
import
net.mamoe.mirai.message.Image
...
@@ -8,7 +9,6 @@ import org.jsoup.Jsoup
...
@@ -8,7 +9,6 @@ import org.jsoup.Jsoup
class
GentleImage
{
class
GentleImage
{
lateinit
var
tags
:
String
lateinit
var
tags
:
String
lateinit
var
sample_url
:
String
lateinit
var
author
:
String
lateinit
var
author
:
String
lateinit
var
file_url
:
String
lateinit
var
file_url
:
String
...
@@ -39,7 +39,16 @@ class GentleImage {
...
@@ -39,7 +39,16 @@ class GentleImage {
GlobalScope
.
async
{
GlobalScope
.
async
{
delay
((
Math
.
random
()
*
5000L
).
toLong
())
delay
((
Math
.
random
()
*
5000L
).
toLong
())
withContext
(
Dispatchers
.
IO
)
{
withContext
(
Dispatchers
.
IO
)
{
Jsoup
.
connect
(
sample_url
)
class
Result
{
var
id
:
String
=
""
}
val
result
=
JSON
.
parseObject
(
Jsoup
.
connect
(
"http://dev.itxtech.org:10322/v2/randomImg.uue"
).
ignoreContentType
(
true
).
get
().
body
().
text
(),
Result
::
class
.
java
)
Jsoup
.
connect
(
"http://dev.itxtech.org:10322/img.uue?size=large&id=${result.id}"
)
.
userAgent
(
UserAgent
.
randomUserAgent
)
.
userAgent
(
UserAgent
.
randomUserAgent
)
.
timeout
(
20
_0000
)
.
timeout
(
20
_0000
)
.
ignoreContentType
(
true
)
.
ignoreContentType
(
true
)
...
@@ -49,5 +58,6 @@ class GentleImage {
...
@@ -49,5 +58,6 @@ class GentleImage {
}.
upload
(
contact
)
}.
upload
(
contact
)
}
}
}
}
}
}
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Gentleman.kt
View file @
7842ce31
...
@@ -31,7 +31,6 @@ class Gentleman(private val contact: Contact) : Channel<GentleImage> by Channel(
...
@@ -31,7 +31,6 @@ class Gentleman(private val contact: Contact) : Channel<GentleImage> by Channel(
GlobalScope
.
launch
{
GlobalScope
.
launch
{
while
(!
isClosedForSend
)
{
while
(!
isClosedForSend
)
{
send
(
GentleImage
().
apply
{
send
(
GentleImage
().
apply
{
sample_url
=
"http://dev.itxtech.org:10322/randomImg.uue?tdsourcetag=s_pctim_aiomsg&size=large"
contact
=
this
@Gentleman
.
contact
contact
=
this
@Gentleman
.
contact
image
// start downloading
image
// start downloading
...
...
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
View file @
7842ce31
...
@@ -11,7 +11,6 @@ import net.mamoe.mirai.event.Event
...
@@ -11,7 +11,6 @@ import net.mamoe.mirai.event.Event
import
net.mamoe.mirai.event.subscribeAlways
import
net.mamoe.mirai.event.subscribeAlways
import
net.mamoe.mirai.event.subscribeMessages
import
net.mamoe.mirai.event.subscribeMessages
import
net.mamoe.mirai.login
import
net.mamoe.mirai.login
import
net.mamoe.mirai.message.Image
import
net.mamoe.mirai.network.protocol.tim.packet.login.requireSuccess
import
net.mamoe.mirai.network.protocol.tim.packet.login.requireSuccess
import
java.io.File
import
java.io.File
...
@@ -48,9 +47,10 @@ suspend fun main() {
...
@@ -48,9 +47,10 @@ suspend fun main() {
bot
.
subscribeMessages
{
bot
.
subscribeMessages
{
"你好"
reply
"你好!"
"你好"
reply
"你好!"
/*
has<Image> {
has<Image> {
reply(message)
reply(message)
}
}
*/
startsWith
(
"随机图片"
,
removePrefix
=
true
)
{
startsWith
(
"随机图片"
,
removePrefix
=
true
)
{
withContext
(
Dispatchers
.
Default
)
{
withContext
(
Dispatchers
.
Default
)
{
...
...
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