feat: support reverse gif using reply
This commit is contained in:
2 files changed
+19
No files matched your search
@@ -85,6 +85,10 @@ class FancyBot : OneBotListener {
|
||||
val plainTextContent = getMsg.message
|
||||
.filter { it.type == ArrayMessageType.text }
|
||||
.joinToString { it.data.text!! }
|
||||
if (command.contains("倒放") || command.contains("/df")) {
|
||||
// 使用回复消息的方式对一个gif倒放
|
||||
ReverseGIFCommand.reverse(message, getMsg)
|
||||
}
|
||||
if (command.contains("/sl") || command.contains("/short")) {
|
||||
// 使用回复消息的方式快速对一个url消息创建一个短链接
|
||||
message.reply(plainTextContent.trim().makeShortLink())
|
||||
|
||||
@@ -10,6 +10,7 @@ package cn.rtast.fancybot.commands.parse
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.util.misc.makeGif
|
||||
import cn.rtast.fancybot.util.str.encodeToBase64
|
||||
import cn.rtast.rob.entity.GetMessage
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.enums.ArrayMessageType
|
||||
import cn.rtast.rob.util.BaseCommand
|
||||
@@ -34,6 +35,20 @@ class ReverseGIFCommand : BaseCommand() {
|
||||
return gifBytes.encodeToBase64()
|
||||
}
|
||||
|
||||
suspend fun reverse(message: GroupMessage, getMsg: GetMessage.Data) {
|
||||
val imageObject = getMsg.message.find { it.type == ArrayMessageType.image }
|
||||
if (imageObject == null) {
|
||||
message.reply("这个消息中没有图片呢")
|
||||
} else {
|
||||
val url = imageObject.data.file!!
|
||||
val image = this.reverseGif(url)
|
||||
val msg = MessageChain.Builder()
|
||||
.addImage(image, true)
|
||||
.build()
|
||||
message.reply(msg)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun callback(message: GroupMessage) {
|
||||
if (message.sender.userId !in waitingList) return
|
||||
waitingList.removeIf { it == message.sender.userId }
|
||||
|
||||
Reference in New Issue
Block a user