package com.yutou.qqbot.models.Commands;

import com.yutou.napcat.handle.Text;
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 com.yutou.qqbot.utlis.Log;
import com.yutou.napcat.event.MessageEvent;

import java.io.File;

@UseModel
public class BaiduDown extends Model {
    @Override
    public boolean isUserPublic() {
        return false;
    }

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

    @Override
    public String getModelName() {
        return "同步百度云";
    }

    @Override
    public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
        super.onMessage(qq, event, isGroup);
        if (msg.startsWith(QQFromCommands.BAIDU_DOWN)) {
            QQBotManager.getInstance().sendMessage(event.isUser(), qq, new Text("开始同步百度云"));
            AppTools.exec("cd " + new File("baidupan").getAbsolutePath() + " && bypy downdir -v", new ObjectInterface() {
                @Override
                public void out(String data) {
                    super.out(data);
                    Log.i(data);
                    QQBotManager.getInstance().sendMessage(qq, "任务完成");
                }
            }, true, true);
        }
    }
}
