feat: update lib and fix bug

This commit is contained in:
2024-09-24 00:48:23 +08:00
parent d208472b0a
commit 99c1c44ae0
5 files changed
+63 -81

No files matched your search

+15 -25
View File
@@ -75,6 +75,17 @@ class FancyBot : OneBotListener {
calculateResult?.let { message.reply(calculateResult) }
}
ReverseGIFCommand.callback(message)
AsciiArtCommand.callback(message)
if (message.message.any { it.type == ArrayMessageType.reply }) { // Image url parse
val command = message.message.reversed().find { it.type == ArrayMessageType.text }!!.data.text!!
val replyId = message.message.find { it.type == ArrayMessageType.reply }!!.data.id!!
if (command.contains("图来") || command.contains("图链")) {
val getMsg = this.getMessage(replyId.toString().toLong())
ImageURLCommand.callback(message, getMsg)
}
}
coroutineScope.launch {
message.message.forEach {
if (it.type == ArrayMessageType.image) {
@@ -88,8 +99,6 @@ class FancyBot : OneBotListener {
}
}
AsciiArtCommand.callback(message)
if (message.rawMessage.startsWith("https://github.com/") || message.rawMessage.startsWith("git@github.com:")) {
GitHubParseCommand.parse(this, message)
}
@@ -117,22 +126,12 @@ class FancyBot : OneBotListener {
}
BVParseCommand.getShortUrlBVID(shortUrl)
} else {
message.rawMessage.split("?").first().split("/").filter { it.isNotEmpty() && it.isNotBlank() }.last()
message.rawMessage.split("?").first()
.split("/")
.last { it.isNotEmpty() && it.isNotBlank() }
}
BVParseCommand.parse(this, bvid, message)
}
if (message.message.any { it.type == ArrayMessageType.reply }) { // Image url parse
val command = message.message.reversed().find { it.type == ArrayMessageType.text }!!.data.text!!
val replyId = message.message.find { it.type == ArrayMessageType.reply }!!.data.id!!
if (command.contains("图来") || command.contains("图链")) {
// get image url
this.getMessage(replyId.toString().toLong(), "imageUrl", message.groupId)
}
if (command.contains("倒放") || command.contains("df")) {
// reverse gif
this.getMessage(replyId.toString().toLong(), "reverseGif", message.groupId)
}
}
}
override suspend fun onGroupMessageRevoke(message: GroupRevokeMessage) {
@@ -145,15 +144,6 @@ class FancyBot : OneBotListener {
this.sendGroupMessage(message.groupId, msg)
}
override suspend fun onGetGroupMessageResponse(message: GetMessage) {
when (message.data.id) {
"revoke" -> AntiRevokeCommand.callback(this, message)
"imageUrl" -> ImageURLCommand.callback(this, message)
"reverseGif" -> ReverseGIFCommand.callback(this, message)
}
}
override suspend fun onWebsocketErrorEvent(ex: Exception) {
ex.printStackTrace()
}
@@ -209,7 +199,7 @@ val commands = listOf(
AsciiArtCommand(), StatusCommand(),
JueCommand(), ShortLinkCommand(),
TenSetuCommand(), ShotSelfCommand(),
ShotOtherCommand()
ShotOtherCommand(), ReverseGIFCommand()
)
val START_UP_TIME = Instant.now().epochSecond