From 2c8af266b78f7c0c69015ced63c9400bd03cdb64 Mon Sep 17 00:00:00 2001 From: hahwu <31872165+hahwu@users.noreply.github.com> Date: Thu, 26 Feb 2026 10:25:15 +0800 Subject: [PATCH] =?UTF-8?q?notification=E5=8A=9F=E8=83=BD=E5=BC=80?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/game/notification.go | 34 +++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/server/game/notification.go b/src/server/game/notification.go index bf6460a6..44fe2d07 100644 --- a/src/server/game/notification.go +++ b/src/server/game/notification.go @@ -13,9 +13,13 @@ const ( NOTIFY_TYPE_PETROOM_GAME = 2 ) +/* +对方来petroom游戏的通知 +每天最多通知3次 +*/ func NotifyPetroomGame(PlayerId int) { PlayerSimpleData := G_GameLogicPtr.GetSimplePlayerByUid(PlayerId) - if PlayerSimpleData == nil { + if !checkLogout(PlayerSimpleData) { return } count, last := GetPetroomGameNotification(PlayerId) @@ -33,9 +37,13 @@ func NotifyPetroomGame(PlayerId int) { SetPetroomGameNotification(PlayerId, count+1) } +/* +好友申请通知 +好友申请累计两次 +*/ func NotifyFriendApply(PlayerId, FriendId int) { PlayerSimpleData := G_GameLogicPtr.GetSimplePlayerByUid(PlayerId) - if PlayerSimpleData == nil { + if !checkLogout(PlayerSimpleData) { return } FriendSimpleData := G_GameLogicPtr.GetSimplePlayerByUid(FriendId) @@ -52,3 +60,25 @@ func NotifyFriendApply(PlayerId, FriendId int) { GoUtil.NotifyPlayer(GoUtil.Int(PlayerSimpleData.Account), NOTIFY_TYPE_FRIEND_APPLY, title, fmt.Sprintf(info, FriendSimpleData.Name)) SetFriendApplyNotification(PlayerId, count+1) } + +/* +玩家需处于离线状态 +玩家离线时间少于10分钟时,不发送消息 +若用户已连续7天未登入游戏,不再发送通知 +*/ +func checkLogout(PlayerSimpleData *PlayerSimpleData) bool { + if PlayerSimpleData == nil { + return false + } + if PlayerSimpleData.Loginout == 0 { + return false + } + now := GoUtil.Now() + if now-PlayerSimpleData.Loginout > 7*24*3600 { + return false + } + if now-PlayerSimpleData.Loginout < 600 { + return false + } + return true +}