Exemplo n.º 1
0
def init():
    # 读取配置文件
    player_list = config.PLAYER_LIST
    # 读取玩家信息
    for i in player_list:
        nickname = i[0]
        short_steamID = i[1]
        print("{}信息读取完毕, ID:{}".format(nickname, short_steamID))
        long_steamID = steam_id_convert_32_to_64(short_steamID)

        try:
            last_DOTA2_match_ID = DOTA2.get_last_match_id_by_short_steamID(short_steamID)
        except DOTA2.DOTA2HTTPError:
            last_DOTA2_match_ID = "-1"

        # 如果数据库中没有这个人的信息, 则进行数据库插入
        if not is_player_stored(short_steamID):
            # 插入数据库
            insert_info(short_steamID, long_steamID, nickname, last_DOTA2_match_ID)
        # 如果有这个人的信息则更新其最新的比赛信息
        else:
            update_DOTA2_match_ID(short_steamID, last_DOTA2_match_ID)
        # 新建一个玩家对象, 放入玩家列表
        temp_player = player(short_steamID=short_steamID,
                             long_steamID=long_steamID,
                             nickname=nickname,
                             last_DOTA2_match_ID=last_DOTA2_match_ID)

        PLAYER_LIST.append(temp_player)
Exemplo n.º 2
0
def init():
    # 读取配置文件
    try:
        config = json.load(open("config.json", "r", encoding='UTF-8'))
        DOTA2.api_key = config["api_key"]
        message_sender.url = config["mirai_url"]
        message_sender.authKey = config["mirai_auth_key"]
        message_sender.bot_qq = config["bot_qq"]
        message_sender.target = config["qq_group_id"]
        player_list = config["player_list"]
        is_update_DOTA2 = config["is_update_DOTA2"]
        is_update_CSGO = config["is_update_CSGO"]
    except Exception:
        print("读取配置文件失败, 请检查配置文件")
        return -1
    # 读取玩家信息
    for i in player_list:
        nickname = i[0]
        short_steamID = i[1]
        print("{}信息读取完毕, ID:{}".format(nickname, short_steamID))
        long_steamID = steam_id_convert_32_to_64(short_steamID)
        try:
            last_CSGO_match_info = CSGO.get_last_match_by_long_steamID(
                long_steamID)
            last_CSGO_match_ID = last_CSGO_match_info["matchId"]
        except CSGO.CSGOHTTPError:  # 这人没打过CSGO
            last_CSGO_match_ID = "-1"
            last_CSGO_match_info = "-1"

        try:
            last_DOTA2_match_ID = DOTA2.get_last_match_id_by_short_steamID(
                short_steamID)
        except DOTA2.DOTA2HTTPError:
            last_DOTA2_match_ID = "-1"

        # 如果数据库中没有这个人的信息, 则进行数据库插入
        if not is_player_stored(short_steamID):
            # 插入数据库
            insert_info(short_steamID, long_steamID, nickname,
                        last_CSGO_match_ID, last_DOTA2_match_ID)
        # 如果有这个人的信息则更新其最新的比赛信息
        else:
            update_CSGO_match_ID(short_steamID, last_CSGO_match_ID)
            update_DOTA2_match_ID(short_steamID, last_DOTA2_match_ID)
        # 新建一个玩家对象, 放入玩家列表
        temp_player = player(short_steamID=short_steamID,
                             long_steamID=long_steamID,
                             nickname=nickname,
                             last_CSGO_match_ID=last_CSGO_match_ID,
                             last_DOTA2_match_ID=last_DOTA2_match_ID)
        if last_CSGO_match_info != "-1":
            temp_player.csgo_data_set(last_CSGO_match_info)

        PLAYER_LIST.append(temp_player)
Exemplo n.º 3
0
def init():
    # 读取配置文件
    parser = argparse.ArgumentParser()
    parser.add_argument('-c', '--config', default='./config.json')
    try:
        args = parser.parse_args()
        config = json.load(open(args.config, "r", encoding='UTF-8'))
        DOTA2.api_key = config["api_key"]
        message_sender.url = config["opq_url"]
        message_sender.bot_qq = config["bot_qq"]
        message_sender.admin_qq = config["admin_qq"]
        message_sender.target = config["qq_group_id"]
        player_list = config["player_list"]
    except Exception:
        print("读取配置文件失败, 请检查配置文件")
        return -1
    # 读取玩家信息
    for i in player_list:
        nickname = i[0]
        short_steamID = i[1]
        qqid = i[2]
        print("{}信息读取完毕, ID:{}, qq:{}".format(nickname, short_steamID, qqid))
        long_steamID = steam_id_convert_32_to_64(short_steamID)

        try:
            last_DOTA2_match_ID = DOTA2.get_last_match_id_by_short_steamID(
                short_steamID)
        except DOTA2.DOTA2HTTPError:
            last_DOTA2_match_ID = "-1"

        # 如果数据库中没有这个人的信息, 则进行数据库插入
        if not is_player_stored(short_steamID):
            # 插入数据库
            insert_info(short_steamID, long_steamID, qqid, nickname,
                        last_DOTA2_match_ID)
        # 如果有这个人的信息则更新其最新的比赛信息
        else:
            update_DOTA2_match_ID(short_steamID, last_DOTA2_match_ID)
        # 新建一个玩家对象, 放入玩家列表
        temp_player = player(short_steamID=short_steamID,
                             long_steamID=long_steamID,
                             qqid=qqid,
                             nickname=nickname,
                             last_DOTA2_match_ID=last_DOTA2_match_ID)

        PLAYER_LIST.append(temp_player)
Exemplo n.º 4
0
def update_DOTA2() -> Dict:
    result = {}
    for i in PLAYER_LIST:
        try:
            match_id = DOTA2.get_last_match_id_by_short_steamID(i.short_steamID)
        except DOTA2.DOTA2HTTPError:
            continue
        if match_id != i.last_DOTA2_match_ID:

            if result.get(match_id, 0) != 0:
                result[match_id].append(i)
            else:
                result.update({match_id: [i]})
            # 更新数据库的last_DOTA2_match_id字段
            update_DOTA2_match_ID(i.short_steamID, match_id)
            # 更新列表
            i.last_DOTA2_match_ID = match_id

    return result
Exemplo n.º 5
0
def init():
    for nickname, short_steamID in json.load(open("list.json", "r")).items():

        long_steamID = steam_id_convert_32_to_64(short_steamID)
        try:
            last_CSGO_match_info = CSGO.get_last_match_by_long_steamID(
                long_steamID)
            last_CSGO_match_ID = last_CSGO_match_info["matchId"]
        except CSGO.CSGOHTTPError:  # 这人没打过CSGO
            last_CSGO_match_ID = "-1"
            last_CSGO_match_info = "-1"

        try:
            last_DOTA2_match_ID = DOTA2.get_last_match_id_by_short_steamID(
                short_steamID)
        except DOTA2.DOTA2HTTPError:
            last_DOTA2_match_ID = "-1"

        # 如果数据库中没有这个人的信息, 则进行数据库插入
        if not is_player_stored(short_steamID):
            # 插入数据库
            insert_info(short_steamID, long_steamID, nickname,
                        last_CSGO_match_ID, last_DOTA2_match_ID)
        # 如果有这个人的信息则更新其最新的比赛信息
        else:
            update_CSGO_match_ID(short_steamID, last_CSGO_match_ID)
            update_DOTA2_match_ID(short_steamID, last_DOTA2_match_ID)
        # 新建一个玩家对象, 放入玩家列表
        temp_player = player(short_steamID=short_steamID,
                             long_steamID=long_steamID,
                             nickname=nickname,
                             last_CSGO_match_ID=last_CSGO_match_ID,
                             last_DOTA2_match_ID=last_DOTA2_match_ID)
        if last_CSGO_match_info != "-1":
            temp_player.csgo_data_set(last_CSGO_match_info)

        PLAYER_LIST.append(temp_player)