Ejemplo n.º 1
0
        private static void WhitelistUser(APIUser user)
        {
            if (user == null)
            {
                return;
            }

            if (UserPermissionHandler.IsWhitelisted(user.id))
            {
                UserPermissionHandler.RemoveFromWhitelist(user.id);
                MelonLogger.Msg($"{user.displayName} removed from whitelist");
                Utilities.QueueHudMessage($"{user.displayName} removed from whitelist");
            }
            else
            {
                if (UserPermissionHandler.IsBlacklisted(user.id))
                {
                    UserPermissionHandler.RemoveFromBlacklist(user.id);
                }
                UserPermissionHandler.AddToWhitelist(user);
                MelonLogger.Msg($"{user.displayName} added to whitelist");
                Utilities.QueueHudMessage($"{user.displayName} added to whitelist");
            }

            UserPermissionHandler.SaveSettings();
        }
Ejemplo n.º 2
0
        private static void HandleNotification(ref Notification notification)
        {
            if (Utilities.GetStreamerMode())
            {
                return;
            }

            // Original code doesn't handle much outside worlds so
            if (Utilities.CurrentRoom() == null ||
                Utilities.CurrentWorldInstance() == null)
            {
                return;
            }

            if (notification.notificationType != null)
            {
                switch (notification.notificationType.ToLowerInvariant())
                {
                case "invite":
#if DEBUG
                    if (notification.details?.keys != null)
                    {
                        foreach (string key in notification.details?.keys)
                        {
                            Utilities.LoggerInstance.Msg("Invite Details Key: " + key);
                            if (notification.details != null)
                            {
                                Utilities.LoggerInstance.Msg("Invite Details Value: " + notification.details[key].ToString());
                            }
                        }
                    }
#endif

                    if (APIUser.CurrentUser.statusIsSetToDoNotDisturb &&
                        !ignoreBusyStatus)
                    {
                        return;
                    }

                    string worldId = notification.details?["worldId"].ToString().Split(':')[0];
                    if (blacklistEnabled && (UserPermissionHandler.IsBlacklisted(notification.senderUserId) || WorldPermissionHandler.IsBlacklisted(worldId)))
                    {
                        Utilities.DeleteNotification(notification);
                        return;
                    }

                    if (inviteSoundEnabled)
                    {
                        SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.Invite);
                    }
                    break;

                case "requestinvite":
                    if (blacklistEnabled && UserPermissionHandler.IsBlacklisted(notification.senderUserId))
                    {
                        Utilities.DeleteNotification(notification);
                        return;
                    }

                    if (APIUser.CurrentUser.statusIsSetToDoNotDisturb &&
                        !ignoreBusyStatus)
                    {
                        return;
                    }

                    if (whitelistEnabled && UserPermissionHandler.IsWhitelisted(notification.senderUserId))
                    {
                        if (!Utilities.AllowedToInvite())
                        {
                            if (inviteRequestSoundEnabled)
                            {
                                SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.InviteRequest);
                            }
                            return;
                        }

                        if (notification.details?.ContainsKey("platform") == true &&
                            !Utilities.IsPlatformCompatibleWithCurrentWorld(notification.details["platform"].ToString()))
                        {
                            if (!APIUser.CurrentUser.statusIsSetToJoinMe)
                            {
                                // Bool's doesn't work and closes the game. just let it through
                                //Utilities.SendIncompatiblePlatformNotification(__0.senderUserId);
                                //Utilities.DeleteNotification(__0);
                                if (inviteRequestSoundEnabled)
                                {
                                    SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.InviteRequest);
                                }
                            }

                            return;
                        }

                        // Double Sending
                        if (!APIUser.CurrentUser.statusIsSetToJoinMe)
                        {
                            Utilities.AcceptInviteRequest(notification.senderUserId, notification.senderUsername);
                            Utilities.DeleteNotification(notification);
                        }

                        if (APIUser.CurrentUser.statusIsSetToJoinMe && joinMeNotifyRequest)
                        {
                            if (inviteRequestSoundEnabled)
                            {
                                SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.InviteRequest);
                            }
                        }
                    }
                    else
                    {
                        if (Utilities.AllowedToInvite())
                        {
                            if (APIUser.CurrentUser.statusIsSetToJoinMe &&
                                !joinMeNotifyRequest)
                            {
                                return;
                            }
                        }
                        if (inviteRequestSoundEnabled)
                        {
                            SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.InviteRequest);
                        }
                    }

                    return;

                // ReSharper disable StringLiteralTypo
                case "votetokick":
                    if (voteToKickSoundEnabled)
                    {
                        SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.VoteToKick);
                    }
                    break;

                case "friendrequest":
                    if (friendRequestSoundEnabled)
                    {
                        SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.FriendRequest);
                    }
                    break;

                default:
                    return;
                }
            }
        }