Exemplo n.º 1
0
def open_turing_ai_set_file():
    '''
    用系统文本软件打开  图灵AI设置文件.json
    '''
    from infoTool.load_Project_Location import get_resourceLocation
    location = get_resourceLocation(
    ) + "/Manager/TalkWidget/Judgement/TuringAI.json"
    from controller.system_shell_console import open_or_run
    open_or_run({"softwareLocation": location})
Exemplo n.º 2
0
def open_command_matching_mapper_file():
    '''
    用系统文本软件打开  命令匹配mapper.json
    '''
    from infoTool.load_Project_Location import get_resourceLocation
    location = get_resourceLocation(
    ) + "/Manager/TalkWidget/Judgement/CommandMatchingMapper.json"
    from controller.system_shell_console import open_or_run
    open_or_run({"softwareLocation": location})
Exemplo n.º 3
0
def open_software_mapper_file():
    '''
    用系统文本软件打开  软件mapper.json
    '''
    from infoTool.load_Project_Location import get_resourceLocation
    location = get_resourceLocation(
    ) + "/Manager/TalkWidget/SoftwareMapper.json"
    from controller.system_shell_console import open_or_run
    open_or_run({"softwareLocation": location})
Exemplo n.º 4
0
def add_compressed_id(the_id):
    '''
    添加id到已经被tinyPNG压缩的记录表中
    '''
    location = get_resourceLocation() + "Manager/Tool/TinyPNG/TinyNote.json"
    with open(location, "r") as f:
        have_compress_dict = json.load(f)
    have_compress_dict[the_id] = 1
    with open(location, "w") as f:
        json.dump(have_compress_dict, f)
Exemplo n.º 5
0
def open_judgement_folder():
    '''
    打开判断模型文件夹
    '''
    from infoTool.load_Project_Location import get_resourceLocation
    from infoTool.cmd_helper import system_shell
    location = get_resourceLocation(
    ) + "Manager/TalkWidget/Judgement/JudgeModel"
    command = "start " + location
    system_shell(command)
Exemplo n.º 6
0
def is_id_had_compressed(the_id):
    '''
    检查传入的id是否已经被添加到压缩记录中
    '''
    location = get_resourceLocation() + "Manager/Tool/TinyPNG/TinyNote.json"
    with open(location, "r") as f:
        have_compress_dict = json.load(f)
    if (have_compress_dict.get(the_id) is None):
        return False
    else:
        return True
Exemplo n.º 7
0
def save_command_matching_state():
    '''
    保存命令匹配状态到文件中
    文件路径:/resource/Manager/TalkWidget/Judgement/CommandMatchingMapper.json
    '''
    from infoTool.load_Project_Location import get_resourceLocation
    match_mapper_location = get_resourceLocation(
    ) + "Manager/TalkWidget/Judgement/CommandMatchingMapper.json"
    global matching_dict
    with open(match_mapper_location, "w") as f:
        json.dump(matching_dict, f, indent=4)
Exemplo n.º 8
0
def _loading_matching_dict():
    # 读取mapper
    from infoTool.load_Project_Location import get_resourceLocation
    match_mapper_location = get_resourceLocation(
    ) + "Manager/TalkWidget/Judgement/CommandMatchingMapper.json"
    global matching_dict
    try:
        with open(match_mapper_location, "r") as f:
            matching_dict = json.load(f)
    except:
        print("读取匹配mapper失败")
Exemplo n.º 9
0
def _load_turing_userdata():
    '''
    读取用户接入数据
    '''
    global turing_user_info_dict

    from infoTool.load_Project_Location import get_resourceLocation
    location = get_resourceLocation(
    ) + "Manager/TalkWidget/Judgement/TuringAI.json"

    with open(location, "r") as f:
        turing_user_info_dict = json.load(f)
Exemplo n.º 10
0
def _load_introduce(judge_key):
    '''读取介绍,去resource/Manager/TalkWidget/Text/Introduce/下尝试读取对应txt文件'''
    global judge_introduce_dict
    from infoTool.load_Project_Location import get_resourceLocation
    location = get_resourceLocation(
    ) + "Manager/TalkWidget/Text/Introduce/" + judge_key + ".txt"
    try:
        with open(location, "r") as f:
            introduce = f.read()
        judge_introduce_dict[judge_key] = introduce
    except:
        introduce = _load_introduce("default")
    return introduce
Exemplo n.º 11
0
def _load_tinyPNG_api_key():
    '''
    读取TinyPNG的API_key,API_key需要去官网获取(一个月免费用500次)
    '''
    global tinypng_api_key
    if (tinypng_api_key is not None):
        return tinypng_api_key

    apikey_file_location = get_resourceLocation(
    ) + "Manager/Tool/TinyPNG/TinyPNG_api_key.ini"
    with open(apikey_file_location, "r") as f:
        api_key = f.read()
    tinypng_api_key = api_key
    return api_key
Exemplo n.º 12
0
def scan_FairyXML(reScan=False):
    #扫描resource文件夹下的xml,将找到的xml文件路径,保存到CutieXmlDict
    # 当再次调用函数,如果不传入True,那么将直接用上次的结果返回

    global CutieXmlDict
    if (CutieXmlDict is None or reScan == True):
        # 获取资源路径下所有xml文件,认为都是Fairy注册文件。
        from infoTool.load_Project_Location import get_resourceLocation
        location = get_resourceLocation()
        from infoTool.scan_file import scan_file
        xmlDict = scan_file(location, "xml")
        return xmlDict
    else:  # 当已经扫描过,且未要求再次扫描时。直接返回以前扫描的结果回去
        return CutieXmlDict
Exemplo n.º 13
0
def _init():
    global bot
    global ice
    print("小冰AI初始化......")
    # 设置一个保存登陆账户文件的文件
    loacation = get_resourceLocation()+"Manager/TalkWidget/reply/wxpy.pkl"
    
    # 初始化机器人,扫码登陆
    bot = Bot(cache_path=loacation)
    ice = bot.mps(update=False).search("小冰") # 在公众号里找到小冰
    if(len(ice) == 1):
        ice = ice[0]
    else:
        global ice_reply
        ice_reply ="尚未关注小冰"
    
    # 注册事件,当接收到来自小冰的信息时,执行,将信息保存
    @bot.register(chats=ice)
    def print_group_msg(msg):
        global ice_reply
        if(ice_reply is None):
            ice_reply = msg
        if(isinstance(ice_reply, str)):
            ice_reply = ice_reply + msg
Exemplo n.º 14
0
def copy_file_to_resource(source_file_location):
    file_name = source_file_location.split("/")[-1]
    from infoTool.load_Project_Location import get_resourceLocation
    _copy_file(source_file_location, get_resourceLocation() + file_name)
Exemplo n.º 15
0
def get_resource_location():
    '''
    获取资源路径
    '''
    from infoTool.load_Project_Location import get_resourceLocation
    return get_resourceLocation()