package com.yutou.qqbot.models.Commands;

import com.yutou.qqbot.Annotations.UseModel;
import com.yutou.qqbot.QQBotManager;
import com.yutou.qqbot.interfaces.ObjectInterface;
import com.yutou.qqbot.models.Model;
import com.yutou.qqbot.utlis.AppTools;
import net.mamoe.mirai.event.events.MessageEvent;
@UseModel
public class BTDownload extends Model {
    private static final String DownloadHomePath="/media/yutou/disk_lvm/public/download/";
    @Override
    public boolean isUserPublic() {
        return false;
    }

    @Override
    public String[] getUsePowers() {
        return new String[]{
                QQFromCommands.BT_DOWNLOAD
        };
    }

    @Override
    public String getModelName() {
        return "添加BT下载";
    }

    @Override
    public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
        super.onMessage(qq, event, isGroup);
        if(msg.startsWith("magnet:?xt=")){
            String builder = "已添加下载磁链"  ;
            QQBotManager.getInstance().sendMessage(qq, builder);
            String exec = String.format("qbittorrent-nox  --save-path=%sdownload_tmp/%s \"%s\" "
                    ,DownloadHomePath
                    , AppTools.getToDayTime()
                    , msg
            );
            AppTools.exec(exec, new ObjectInterface() {
                @Override
                public void out(String data) {
                    super.out(data);
                }
            },true,false);
        }
    }
}
