@@ -127,6 +127,44 @@ class KookBot(private val plugin: PlumBot): Bot {
127
127
}
128
128
}
129
129
130
+ /* *
131
+ * Send a picture to group
132
+ * @param targetId ID of the target
133
+ * @param message Message to send
134
+ */
135
+ override fun sendGroupPicWithText (targetId : String , message : String ) {
136
+ val channel = kookClient.core.httpAPI.getChannel(targetId) as TextChannel
137
+ val list: MutableList <ImageElement > = ArrayList ()
138
+ list.add(ImageElement (createPicWithText(message), " " , false ))
139
+ val card: MultipleCardComponent = CardBuilder ()
140
+ .setTheme(Theme .PRIMARY )
141
+ .setSize(Size .LG )
142
+ .addModule(ContainerModule (list))
143
+ .build()
144
+ submitAsync(now = true ) {
145
+ channel.sendComponent(card)
146
+ }
147
+ }
148
+
149
+ /* *
150
+ * Send a picture to user
151
+ * @param targetId ID of the target
152
+ * @param message Message to send
153
+ */
154
+ override fun sendUserPicWithText (targetId : String , message : String ) {
155
+ val user = kookClient.core.httpAPI.getUser(targetId)
156
+ val list: MutableList <ImageElement > = ArrayList ()
157
+ list.add(ImageElement (createPicWithText(message), " " , false ))
158
+ val card: MultipleCardComponent = CardBuilder ()
159
+ .setTheme(Theme .PRIMARY )
160
+ .setSize(Size .LG )
161
+ .addModule(ContainerModule (list))
162
+ .build()
163
+ submitAsync(now = true ) {
164
+ user.sendPrivateMessage(card)
165
+ }
166
+ }
167
+
130
168
131
169
/* *
132
170
* Send message to the group/user
@@ -179,7 +217,7 @@ class KookBot(private val plugin: PlumBot): Bot {
179
217
user.sendPrivateMessage(s)
180
218
}
181
219
182
- private fun createFile (s : String ): String? {
220
+ private fun createPicWithText (s : String ): String? {
183
221
try {
184
222
val file = File .createTempFile(" PlumBot-" , " .png" )
185
223
val fos = FileOutputStream (file)
@@ -192,9 +230,9 @@ class KookBot(private val plugin: PlumBot): Bot {
192
230
return null
193
231
}
194
232
195
- fun sendPrivateFileReply (e : PrivateMessageReceivedEvent , s : String ) {
233
+ fun sendPrivatePicReplyWithText (e : PrivateMessageReceivedEvent , s : String ) {
196
234
val list: MutableList <ImageElement > = ArrayList ()
197
- list.add(ImageElement (createFile (s), " " , false ))
235
+ list.add(ImageElement (createPicWithText (s), " " , false ))
198
236
val card: MultipleCardComponent = CardBuilder ()
199
237
.setTheme(Theme .PRIMARY )
200
238
.setSize(Size .LG )
@@ -207,7 +245,7 @@ class KookBot(private val plugin: PlumBot): Bot {
207
245
208
246
fun sendChannelFileReply (e : ChannelMessageEvent , s : String ) {
209
247
val list: MutableList <ImageElement > = ArrayList ()
210
- list.add(ImageElement (createFile (s), " " , false ))
248
+ list.add(ImageElement (createPicWithText (s), " " , false ))
211
249
val card: MultipleCardComponent = CardBuilder ()
212
250
.setTheme(Theme .PRIMARY )
213
251
.setSize(Size .LG )
0 commit comments