def isVerfied(userId): """ 是否已实名认证 """ # vertified = gamedata.getGameAttrInt(userId, FISH_GAMEID, GameData.vertified) # if vertified: # return True ts = int(time.time()) requestUrl = "https://fcmapi.tuyoo.com" + "/anti-addiction/v1/user/query/info.json" # 键值对升序排列 signStr = "access_id=15e347e88f55a87d&secret_type=forever&sign_type=sha256&ts=%d&user_id=%d:dgI64ZhCoE6fjld2Ph5bhzukLlFpuvHB" % ( ts, userId) import hashlib sign = str(hashlib.sha256(signStr).hexdigest().lower()) postData = {"access_id": "15e347e88f55a87d", "sign_type": "sha256", "secret_type": "forever", "ts": ts, "user_id": userId, "sign": sign} try: result = util.doHttpQuery(requestUrl, postData) if ftlog.is_debug(): ftlog.debug("query verfied, postData =", postData, "result =", result) if result and result.get("code") == 0 and result.get("result", {}).get("verified", 0): # gamedata.setGameAttr(userId, FISH_GAMEID, GameData.vertified, 1) return True except: ftlog.error("query verfied error !", userId) return False
def refreshUserData(userId): """ 刷新用户是否存在地区限制 """ location = config.getPublic("locationLimit", []) requestUrl = "http://iploc.ywdier.com/api/iploc5/search/city" postData = {"ip": sessiondata.getClientIp(userId)} result = util.doHttpQuery(requestUrl, postData, timeout=3) isLocationLimit = 0 if not result or set(location) & set(result.get("loc", [])): isLocationLimit = 1 gamedata.setGameAttr(userId, FISH_GAMEID, GameData.isLocationLimit, isLocationLimit)
def executeForbidden(userId, isForbidden): """ 对玩家执行封禁/解除封禁 :return: 0:执行成功 1:执行失败 """ requestUrl = gdata.httpGame() + "/open/v3/user/setForbidden" if isForbidden: postData = {"lock_users": [userId]} else: postData = {"unlock_users": [userId]} try: result = util.doHttpQuery(requestUrl, postData, timeout=3) if result and result.get("error") is None: return 0 except: ftlog.error("executeForbidden error", userId, isForbidden) return 1
def isFollowAccount(userId): """ 是否关注微信公众号 """ followAccount = gamedata.getGameAttrInt(userId, FISH_GAMEID, GameData.followAccount) if followAccount: return True requestUrl = gdata.httpGame() + "/open/v4/user/act/wx/checkfollowmp" postData = { "userId": userId, "wxgameappid": config.WX_APPID, "wxmpappid": config.WX_MP_APPID } result = util.doHttpQuery(requestUrl, postData) if result and result.get("result", {}).get("follow") is True: gamedata.setGameAttr(userId, FISH_GAMEID, GameData.followAccount, 1) return True return False
def queryForbidden(userId): """ 查询玩家账号是否被封禁 :return: 0:未封禁 1:已封禁 """ requestUrl = gdata.httpGame() + "/open/v4/tools/query_forbidden" signStr = "access_id=wa15b4444ce9d977f4&user_Id=%d:G64RBRAkKh57PR0EWZqsVE5H4GiPKPx7" % userId import hashlib sign = str(hashlib.sha256(signStr).hexdigest().lower()) postData = {"user_Id": userId, "access_id": "wa15b4444ce9d977f4", "sign": sign} try: result = util.doHttpQuery(requestUrl, postData) if result and result.get("result", {}).get("code") == 1: return 1 except: ftlog.error("queryForbidden error", userId) return 0