fix: fix speed up will reverse gif
This commit is contained in:
3 files changed
+32
-28
No files matched your search
@@ -94,40 +94,27 @@ class FancyBot : OneBotListener {
|
|||||||
val plainTextContent = getMsg.message
|
val plainTextContent = getMsg.message
|
||||||
.filter { it.type == ArrayMessageType.text }
|
.filter { it.type == ArrayMessageType.text }
|
||||||
.joinToString { it.data.text!! }
|
.joinToString { it.data.text!! }
|
||||||
if (command.contains("加速")) {
|
if (command.contains("倒放") || command.contains("/df")) ReverseGIFCommand.reverse(message, getMsg)
|
||||||
val multiply = command.split("加速").last().toFloat()
|
if (command.contains("图来") || command.contains("图链")) ImageURLCommand.callback(message, getMsg)
|
||||||
SpeedUpGIFCommand.speedUp(message, getMsg, multiply)
|
if (command.contains("reaction")) ReactionCommand.reaction(message)
|
||||||
}
|
if (command.contains("图床")) ImageBedCommand.execute(getMsg, message)
|
||||||
if (command.contains("倒放") || command.contains("/df")) {
|
if (command.contains("/sl") || command.contains("/short")) message.reply(
|
||||||
// 使用回复消息的方式对一个gif倒放
|
plainTextContent.trim().makeShortLink()
|
||||||
ReverseGIFCommand.reverse(message, getMsg)
|
)
|
||||||
}
|
|
||||||
if (command.contains("/sl") || command.contains("/short")) {
|
|
||||||
// 使用回复消息的方式快速对一个url消息创建一个短链接
|
|
||||||
message.reply(plainTextContent.trim().makeShortLink())
|
|
||||||
}
|
|
||||||
if (command.contains("/pb") || command.contains("/pastebin")) {
|
|
||||||
// 使用回复消息的方式快速将创建一个pastebin
|
|
||||||
val pastebinUrl = PastebinCommand.createPastebin(plainTextContent)
|
|
||||||
message.reply(pastebinUrl)
|
|
||||||
}
|
|
||||||
if (command.contains("/ascii") || command.contains("/asc")) {
|
if (command.contains("/ascii") || command.contains("/asc")) {
|
||||||
// 使用回复消息的方式直接对一个图片进行生成Ascii art的操作
|
// 使用回复消息的方式直接对一个图片进行生成Ascii art的操作
|
||||||
val url = AsciiArtCommand.getImageUrl(getMsg)
|
val url = AsciiArtCommand.getImageUrl(getMsg)
|
||||||
val image = AsciiArtCommand.generateAsciiArt(url)
|
val image = AsciiArtCommand.generateAsciiArt(url)
|
||||||
message.reply(image)
|
message.reply(image)
|
||||||
}
|
}
|
||||||
if (command.contains("图来") || command.contains("图链")) {
|
if (command.contains("/pb") || command.contains("/pastebin")) {
|
||||||
// 获取一个或多个图片的链接, 并且生成一个或多个短链接
|
// 使用回复消息的方式快速将创建一个pastebin
|
||||||
ImageURLCommand.callback(message, getMsg)
|
val pastebinUrl = PastebinCommand.createPastebin(plainTextContent)
|
||||||
|
message.reply(pastebinUrl)
|
||||||
}
|
}
|
||||||
if (command.contains("reaction")) {
|
if (command.contains("加速")) {
|
||||||
// 使用reaction刷屏回应一条消息
|
val multiply = command.split("加速").last().toFloat()
|
||||||
ReactionCommand.reaction(message)
|
SpeedUpGIFCommand.speedUp(message, getMsg, multiply)
|
||||||
}
|
|
||||||
if (command.contains("图床")) {
|
|
||||||
// 将一个图片上传到图床
|
|
||||||
ImageBedCommand.execute(getMsg, message)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ object SpeedUpGIFCommand {
|
|||||||
val gifStream = gifUrl.toURL().openStream()
|
val gifStream = gifUrl.toURL().openStream()
|
||||||
val decoder = GifDecoder()
|
val decoder = GifDecoder()
|
||||||
decoder.read(gifStream)
|
decoder.read(gifStream)
|
||||||
val frames = (0 until decoder.frameCount).map { decoder.getFrame(it) }.reversed()
|
val frames = (0 until decoder.frameCount).map { decoder.getFrame(it) }
|
||||||
val gifBase64 = decoder.makeGif(frames, multiply)
|
val gifBase64 = decoder.makeGif(frames, multiply)
|
||||||
val imgBedUrl = ImageBed.upload(gifBase64)
|
val imgBedUrl = ImageBed.upload(gifBase64)
|
||||||
val shortLink = imgBedUrl.makeShortLink()
|
val shortLink = imgBedUrl.makeShortLink()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
package cn.rtast.fancybot.util.misc
|
package cn.rtast.fancybot.util.misc
|
||||||
|
|
||||||
import cn.rtast.fancybot.configManager
|
import cn.rtast.fancybot.configManager
|
||||||
|
import java.awt.Color
|
||||||
import java.awt.Graphics2D
|
import java.awt.Graphics2D
|
||||||
import java.awt.geom.Ellipse2D
|
import java.awt.geom.Ellipse2D
|
||||||
import java.awt.geom.RoundRectangle2D
|
import java.awt.geom.RoundRectangle2D
|
||||||
@@ -129,3 +130,19 @@ fun BufferedImage.isFullyTransparent(): Boolean {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun BufferedImage.toGrayscale(): BufferedImage {
|
||||||
|
val width = this.width
|
||||||
|
val height = this.height
|
||||||
|
val grayscaleImage = BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY)
|
||||||
|
|
||||||
|
for (y in 0 until height) {
|
||||||
|
for (x in 0 until width) {
|
||||||
|
val color = Color(this.getRGB(x, y))
|
||||||
|
val gray = (color.red * 0.299 + color.green * 0.587 + color.blue * 0.114).toInt()
|
||||||
|
val grayColor = Color(gray, gray, gray)
|
||||||
|
grayscaleImage.setRGB(x, y, grayColor.rgb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return grayscaleImage
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user