package com.yutou.qqbot.models.Commands;

import com.yutou.qqbot.Annotations.UseModel;
import com.yutou.qqbot.QQBotManager;
import com.yutou.qqbot.models.Model;
import net.mamoe.mirai.contact.AudioSupported;
import net.mamoe.mirai.event.events.MessageEvent;
import net.mamoe.mirai.message.data.Audio;
import net.mamoe.mirai.message.data.MessageChainBuilder;
import net.mamoe.mirai.message.data.OfflineAudio;
import net.mamoe.mirai.utils.ExternalResource;

import java.io.File;
import java.util.Objects;

import static com.yutou.qqbot.models.Model.QQGroupCommands.QQ_WOODEN;

@UseModel
public class WoodenFish extends Model {
    @Override
    public boolean isUserPublic() {
        return true;
    }

    @Override
    public String[] getUsePowers() {
        return new String[0];
    }

    @Override
    public String getModelName() {
        return "电子木鱼";
    }

    @Override
    public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
        super.onMessage(qq, event, isGroup);
        File file = null;
        if(msg.contains("地狱笑话")){
            file=new File("muyu.mp3");
            QQBotManager.getInstance().sendMessage(qq,"功德+1");
        }else if(msg.contains("遥遥领先")){
            file=new File("遥遥领先.silk");
        }
        if(file!=null){
            if(file.exists()) {
                OfflineAudio audio = Objects.requireNonNull(event.getBot().getGroup(qq)).uploadAudio(ExternalResource.create(file));
                MessageChainBuilder builder = new MessageChainBuilder();
                builder.append(audio);
                QQBotManager.getInstance().sendMessage(qq,builder);
            }
        }
    }
}
