| | |
| | | import PlayerControl
|
| | | import PyDataManager
|
| | | import time
|
| | |
|
| | | import json
|
| | | # VIP权限
|
| | | Def_Onoff_VIPCount = 5
|
| | | (
|
| | |
| | |
|
| | | # 新玩家还没有脱机时间 有利于挽回流失玩家
|
| | | g_NewGuyNoTJGTime = {} # {playerID:[playername,getuiid, tick]}
|
| | |
|
| | | g_FMTGeTuiLimit = {} # 封魔坛推送限制 过于频繁控制下短时间通知
|
| | |
|
| | | def ClearFMTGeTuiLimit():
|
| | | global g_FMTGeTuiLimit
|
| | | g_FMTGeTuiLimit = {}
|
| | |
|
| | |
|
| | |
|
| | | def GetTimeLimit(timeStr):
|
| | | # 检查格式后转数字
|
| | |
| | | # 服务端群推暂不由游戏服务器推送,可从第三方个推网站推送
|
| | | # 游戏服务器只推送具有变化性的内容
|
| | | # 支持单推和多人推送
|
| | | # getuiIDList 玩家个推ID
|
| | | # playerNameList 如果存在则必须与getuiIDList一一对应,若不存在则是多推,若存在则会一一单推
|
| | | # appIDDict 混服使用对应不同key {平台ID:[[玩家个推ID, 玩家名],[玩家个推ID2, 玩家名2]。。。]}
|
| | | # 如果玩家名存在则必须与个推ID一一对应,若不存在则是多推,若存在则会一一单推
|
| | | # 带名字会被组合成 格式如【玩家名】您关注的BOSSxx已复活
|
| | | # EventReport_EventReport 向游戏服务器的个推小程序发送 webbottle
|
| | | def GeTuiNotify(getuiIDList, playerNameList, notifyMsg):
|
| | | if type(getuiIDList) != list:
|
| | | def GeTuiNotify(appIDDict, notifyMsg):
|
| | | if not appIDDict:
|
| | | return
|
| | | osName = ReadChConfig.GetPyMongoConfig("GeTui", "OSName")
|
| | | #osName = ReadChConfig.GetPyMongoConfig("GeTui", "OSName") 混服无法配置系统
|
| | | geTuiUrl = ReadChConfig.GetPyMongoConfig("GeTui", "GeTuiUrl")
|
| | |
|
| | | playerNames = "|".join(playerNameList) #组合成字符串发送
|
| | | getuiIDs = "|".join(getuiIDList)
|
| | | |
| | | playerInfo = json.dumps(appIDDict, ensure_ascii=False)
|
| | | #含中文部分要urlencode
|
| | | postInfo = urllib.urlencode({"PlayerName": playerNames, "NotifyMsg":notifyMsg, |
| | | "RegID":getuiIDs, "OSName":osName})
|
| | | postInfo = urllib.urlencode({"PlayerInfo": playerInfo, "NotifyMsg":notifyMsg})
|
| | |
|
| | | GameWorld.GetGameWorld().EventReport_EventReport(postInfo, "", "", "", 1, geTuiUrl)
|
| | | return
|
| | |
| | | return
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | # 判断BOSS剩余次数, 避免通知频繁
|
| | | # 注意玩家次数用完第二天未上线则不会同步BOSS次数,则不推送
|
| | | def CheckBossGeTuiCnt(playerID, bossID, geTuiType, cacheDict):
|
| | | global g_FMTGeTuiLimit
|
| | | |
| | | if geTuiType == Def_GeTui_FMT:
|
| | | if not cacheDict.get("CntMark_%s"%ChConfig.Def_FBMapID_SealDemon, 0):
|
| | | return False
|
| | | |
| | | # 封魔坛比较频繁默认1小时通知一次
|
| | | if playerID not in g_FMTGeTuiLimit:
|
| | | g_FMTGeTuiLimit[playerID] = {}
|
| | | |
| | | lastTime = g_FMTGeTuiLimit[playerID].get(bossID, 0)
|
| | | if lastTime != 0 and time.time() - lastTime < 3600:
|
| | | # 离上次通知还没超过1小时
|
| | | return False
|
| | | |
| | | g_FMTGeTuiLimit[playerID][bossID] = int(time.time())
|
| | | |
| | | |
| | | elif geTuiType == Def_Onoff_Boss:
|
| | | #重生boss
|
| | | killBossCntLimitDict = IpyGameDataPY.GetFuncEvalCfg('KillBossCntLimit', 1, {})
|
| | | for bidlist, bkey in killBossCntLimitDict.items():
|
| | | if bossID not in bidlist:
|
| | | continue
|
| | | if not cacheDict.get("CntMark_%s"%bkey, 0):
|
| | | return False
|
| | | else:
|
| | | return True
|
| | | return True
|
| | | |
| | | def BossAttentionGeTui(bossData, bossID):
|
| | | if bossData.GetMapID() == ChConfig.Def_FBMapID_SealDemon:
|
| | | # 非VIP玩家 封魔坛个推
|
| | |
| | | #找到关注这只BOSS的玩家
|
| | | pdict = PyDataManager.GetBossAttentionManager().GetBossAttentionDict()
|
| | |
|
| | | geTuiIDList = []
|
| | | playerNameList = []
|
| | | |
| | | appIDDict = {} # 混服需要推到不同的个推应用
|
| | | for playerID, bossAttentionData in pdict.items():
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | if curPlayer and not PlayerControl.GetIsTJG(curPlayer):
|
| | |
| | |
|
| | | recordDict = eval(bossAttentionData.RecordData)
|
| | | if recordDict.get(bossID, 0) in [0, 9]:
|
| | | #0-默认未关注, 1-主动关注, 2-自动关注, 9-主动取消关注
|
| | | continue
|
| | | curCache = PlayerViewCache.ViewCacheMgr.FindCache(playerID)
|
| | | if not curCache:
|
| | |
| | | # 过滤个推
|
| | | continue
|
| | |
|
| | | geTuiIDList.append(cacheDict.get("GeTuiClientID", ""))
|
| | | playerNameList.append(cacheDict.get("Name", ""))
|
| | | |
| | | if not CheckBossGeTuiCnt(playerID, bossID, geTuiType, cacheDict):
|
| | | # 判断BOSS剩余次数, 避免通知频繁
|
| | | continue
|
| | | |
| | | appID = cacheDict.get("AppID", "")
|
| | | if appID not in appIDDict:
|
| | | appIDDict[appID] = []
|
| | | |
| | | appIDDict[appID].append([cacheDict.get("GeTuiClientID", ""), cacheDict.get("Name", "")])
|
| | | |
| | |
|
| | | if not geTuiIDList:
|
| | | if not appIDDict:
|
| | | return
|
| | |
|
| | | npcName = GameWorld.GetNPCData(bossID).GetNPCName()
|
| | |
| | | elif geTuiType == Def_Onoff_Boss:
|
| | | showStr = GameWorld.GbkToCode(IpyGameDataPY.GetFuncCfg("GeTuiOffLine", 2)%(bossData.GetSourceName(), npcName, npcLV)) # 文字信息
|
| | |
|
| | | GeTuiNotify(geTuiIDList, playerNameList, showStr)
|
| | | GeTuiNotify(appIDDict, showStr)
|
| | |
|
| | |
|
| | | # 私聊
|
| | |
| | | return
|
| | |
|
| | | showStr = GameWorld.GbkToCode(IpyGameDataPY.GetFuncCfg("GeTuiOffLine", 3))%(tagPlayerName) # 文字信息
|
| | | GeTuiNotify([cacheDict.get("GeTuiClientID", "")], [playerName], showStr)
|
| | | GeTuiNotify({cacheDict.get("AppID", ""):[[cacheDict.get("GeTuiClientID", ""), playerName]]}, showStr)
|
| | | return
|
| | |
|
| | | # 下线时,低级玩家没有离线时间的玩家提示, 上线清空
|
| | |
| | | if curPlayer.GetLV() > 100:
|
| | | return
|
| | | playerID = curPlayer.GetID()
|
| | | g_NewGuyNoTJGTime[playerID] = [curPlayer.GetName(), curPlayer.GetGeTuiClientID(), tick] # curPlayer.GetGeTuiClientID()
|
| | | g_NewGuyNoTJGTime[playerID] = [curPlayer.GetName(), curPlayer.GetGeTuiClientID(), tick, |
| | | GameWorld.GetPlayerPlatform(curPlayer)] # curPlayer.GetGeTuiClientID()
|
| | | return
|
| | |
|
| | | # 上线清除
|
| | |
| | | global g_NewGuyNoTJGTime
|
| | |
|
| | | playerIDList = []
|
| | | geTuiIDs = []
|
| | | playerNames = []
|
| | | appIDDict = {}
|
| | | |
| | | for playerID, getuiInfo in g_NewGuyNoTJGTime.items():
|
| | | if tick - getuiInfo[2] < 300000:
|
| | | continue
|
| | | playerIDList.append(playerID)
|
| | |
|
| | | geTuiIDs.append(getuiInfo[1])
|
| | | playerNames.append(getuiInfo[0])
|
| | | appID = getuiInfo[3]
|
| | | if appID not in appIDDict:
|
| | | appIDDict[appID] = []
|
| | | |
| | | appIDDict[appID].append([getuiInfo[1],getuiInfo[0]])
|
| | |
|
| | | if not geTuiIDs:
|
| | | |
| | | if not appIDDict:
|
| | | return
|
| | | showStr = GameWorld.GbkToCode(IpyGameDataPY.GetFuncCfg("GeTuiOffLine", 4)) # 文字信息
|
| | | GeTuiNotify(geTuiIDs, playerNames, showStr)
|
| | | GeTuiNotify(appIDDict, showStr)
|
| | |
|
| | | for playerID in playerIDList:
|
| | | CleanNewGuyCallBackGeTui(playerID)
|