Skip to content
This repository has been archived by the owner on Nov 24, 2024. It is now read-only.

Commit

Permalink
support image send for ACGCommand by using OverflowAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
guimc233 committed Jan 27, 2024
1 parent 9bf3252 commit f01bfc1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/kotlin/ltd/guimc/lgzbot/command/ACGCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import ltd.guimc.lgzbot.utils.ImageUtils
import ltd.guimc.lgzbot.utils.OverflowUtils
import net.mamoe.mirai.console.command.CommandSender
import net.mamoe.mirai.console.command.SimpleCommand
import net.mamoe.mirai.console.command.getGroupOrNull
import top.mrxiaom.overflow.contact.RemoteBot

object ACGCommand: SimpleCommand (
owner = PluginMain,
Expand All @@ -29,6 +31,7 @@ object ACGCommand: SimpleCommand (

fun CommandSender.ltd_guimc_command_acg() = launch {
requireNotNull(user) { "请在聊天环境中使用该指令" }
val group = getGroupOrNull()
if (!cooldown.isTimePassed(user!!)) {
if (cooldown.shouldSendCooldownNotice(user!!)) sendMessage("你可以在 ${ACGCommand.cooldown.getLeftTime(user!!) / 1000} 秒后继续使用该指令")
return@launch
Expand All @@ -38,7 +41,9 @@ object ACGCommand: SimpleCommand (
if (!OverflowUtils.checkOverflowCore()) {
sendMessage(ImageUtils.url2imageMessage("https://www.dmoe.cc/random.php", bot!!, subject!!))
} else {
sendMessage("由于一些原因 无法发送图片")
if (group != null) {
(bot as RemoteBot).executeAction("send_group_msg", "{\"group_id\": ${group.id}, \"message\": \"[CQ:image,url=https://www.dmoe.cc/random.php]\n\"}")
}
}
} catch (ignore: Throwable) {
sendMessage("Oops, something went wrong.")
Expand Down

0 comments on commit f01bfc1

Please sign in to comment.