@@ -6,24 +6,35 @@ import com.hcyacg.initial.Command
6
6
import com.hcyacg.initial.Config
7
7
import com.hcyacg.initial.Github
8
8
import com.hcyacg.initial.Setting
9
+ import com.hcyacg.lowpoly.LowPoly
9
10
import com.hcyacg.rank.Rank
10
11
import com.hcyacg.rank.Tag
11
12
import com.hcyacg.search.SearchPicCenter
12
13
import com.hcyacg.search.Trace
13
14
import com.hcyacg.sexy.LoliconCenter
14
15
import com.hcyacg.sexy.SexyCenter
16
+ import com.hcyacg.utils.CacheUtil
17
+ import com.hcyacg.utils.DataUtil
18
+ import com.hcyacg.utils.ImageUtil
19
+ import kotlinx.coroutines.Dispatchers
20
+ import kotlinx.coroutines.withContext
15
21
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription
16
22
import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
23
+ import net.mamoe.mirai.contact.Contact.Companion.sendImage
17
24
import net.mamoe.mirai.event.events.BotLeaveEvent
18
25
import net.mamoe.mirai.event.globalEventChannel
19
26
import net.mamoe.mirai.event.subscribeGroupMessages
27
+ import net.mamoe.mirai.message.data.Image
28
+ import net.mamoe.mirai.utils.ExternalResource.Companion.toExternalResource
29
+ import net.mamoe.mirai.utils.ExternalResource.Companion.uploadAsImage
30
+ import java.io.ByteArrayInputStream
20
31
import java.util.regex.Pattern
21
32
22
33
object Pixiv : KotlinPlugin(
23
34
JvmPluginDescription (
24
35
id = "com.hcyacg.pixiv",
25
36
name = "pixiv插画",
26
- version = "1.7.2-fix ",
37
+ version = "1.7.4-future ",
27
38
) {
28
39
author("Nekoer ")
29
40
info("""pixiv插画""")
@@ -126,7 +137,28 @@ object Pixiv : KotlinPlugin(
126
137
val enableSearch = Pattern .compile(" (?i)^(关闭|开启)(ascii2d|google|saucenao|yandex|iqdb)\$ " )
127
138
content { enableSearch.matcher(message.contentToString()).find() } quoteReply { Helper .enableSearch(this ) }
128
139
129
-
140
+ val lowPoly = Pattern .compile(" (?i)^(${Command .lowPoly} ).+\$ " )
141
+ content { lowPoly.matcher(message.contentToString()).find() } quoteReply {
142
+ val picUri = DataUtil .getSubString(this .message.toString().replace(" " , " " ), " [mirai:image:{" , " }." )!!
143
+ .replace(" -" , " " )
144
+ val url = " https://gchat.qpic.cn/gchatpic_new/0/0-0-${picUri} /0?"
145
+ val byte = ImageUtil .getImage(url, CacheUtil .Type .NONSUPPORT ).toByteArray()
146
+ val toExternalResource = LowPoly .generate(
147
+ ByteArrayInputStream (byte),
148
+ 200 ,
149
+ 1F ,
150
+ true ,
151
+ " png" ,
152
+ false ,
153
+ 200
154
+ ).toByteArray().toExternalResource()
155
+
156
+
157
+ withContext(Dispatchers .IO ){
158
+ subject.sendImage(toExternalResource)
159
+ }
160
+ toExternalResource.close()
161
+ }
130
162
// content { "test".contentEquals(message.contentToString()) } quoteReply {PicDetails.getUgoira()}
131
163
132
164
// val coloring: Pattern = Pattern.compile("(?i)^(上色)$")
0 commit comments