package com.ch.jedge.bots.tvass;

import com.ch.jedge.jbot.intent.JDataGetter;
import com.ch.jedge.jbot.intent.JbotApi;
import com.ch.jedge.jbot.intent.JbotData;
import com.ch.jedge.jbot.intent.JedgeJBotCBService;
import com.ch.jedge.jbot.intent.bot.JBotAppBase;
import com.changhong.jedge.JMgbusModual;
import com.changhong.jedge.JMgbusUtil;
import com.changhong.jedge.MgbusApi;
import com.changhong.qlib.intf.QIData;

import java.util.List;

public class JedgeTVAssistant extends JBotAppBase {

    public static class JedgeTVAssService extends JedgeJBotCBService {
        private static final String sval_domain_tv_ctrl_ = "电视控制";
        private static final String sval_domain_media_play_ = "媒体信息";

        private static String cfg_path;

        public JedgeTVAssService(JMgbusModual holder) {
            super(holder);
        }

        @MgbusApi
        @JbotApi( domain = sval_domain_media_play_,
                disc="电影,电视,音乐,纪录片,动画片等各类影视剧的媒体信息查询,播放,包括片名,出品制作方,导演,主要演员,片子简介,剧情简介，包括对U盘或移动硬盘和电视内的媒体文件进行搜索、文件操作或相互拷贝、弹出U盘或移动硬盘等操作。",
                role="电视超脑助手",
                dataset = "媒体指令,媒体名称,播放模式",
                msgFmt = "[{\"command\":\"媒体指令\",\"param\":[\"content=媒体名称\",\"file=拷贝文件\",\"mode=播放模式\",……]}]"
        )
        public QIData tvPlay(QIData eMsg) {
            eMsg.removeKey("~c");
            //
            module.warnLog("Remote call %s", eMsg);
            return JMgbusUtil.MgbusResult(200, "已知悉,但暂未实现完整功能");
        }

        @MgbusApi
        @JbotApi( domain = sval_domain_tv_ctrl_,
                disc="电视机的控制和设置等功能,频道选择,内容推荐,信号源控制等指令,但是不包括媒体影片等信息.",
                role="电视超脑助手",
                dataset = "电视指令",
                msgFmt = "[{\"command\":\"电视指令\",\"param\":[\"额外关键字\",……]}]"
        )
        public QIData tvAsk(QIData eMsg) {
            eMsg.removeKey("~c");
            //
            module.warnLog("Remote call %s", eMsg);
            return JMgbusUtil.MgbusResult(200, "已知悉,但暂未实现完整功能");
        }

        @JbotData( domain = sval_domain_media_play_, words = "媒体指令", nullable = false)
        @JDataGetter
        public List<String> mediaAccessTopics() {
            return loadDataSetFromFile(cfg_path+"/dataset/tvass/media_cmdlist.json");
        }

        @JbotData( domain = sval_domain_tv_ctrl_, words = "电视指令", nullable = false)
        @JDataGetter
        public List<String> commandList() {
            return loadDataSetFromFile(cfg_path+"/dataset/tvass/tv_cmd_list.json");
        }

        @JbotData( domain = sval_domain_media_play_, words = "播放模式", nullable = false)
        @JDataGetter
        public List<String> playMode() {
            return loadDataSetFromFile(cfg_path+"/dataset/tvass/tv_play_mode.json");
        }
    }

    public JedgeTVAssistant(String botName) {
        super(botName);
    }

    public static void TVAss_main(String[] args, String cfgpath) {
        JedgeTVAssistant.JedgeTVAssService.cfg_path = cfgpath;
        run("tvass", JedgeTVAssService.class, args);
    }
}
