Пример #1
0
        private static string HandleRemoveResponse(FriendResponseContainer response, long steamId, string userName, string chatName)
        {
            switch (response.Status)
            {
                case FriendResponseStatus.Added:
                case FriendResponseStatus.Removed:
                case FriendResponseStatus.AlreadyAdded:
                    break;
                case FriendResponseStatus.CantRemove:
                    return string.Format(Texts.RemoveBugAfterDelete, steamId);
                case FriendResponseStatus.Error:
                    return string.Format(Texts.RemoveBug, steamId, response.StatusCode);
                case FriendResponseStatus.NotInFriends:
                    return string.Format(Texts.NotInFriends, steamId, response.Relationship);
                default:
                    throw new ArgumentOutOfRangeException(nameof(response.Status), response.Status, null);
            }

            switch (response.Relationship)
            {
                case FriendResponseRelationship.None:
                    ChatterInfoRepository.Instance.DeleteChatterSteamId(userName, chatName);
                    return string.Format(Texts.Removed, steamId);
                case FriendResponseRelationship.Error:
                    return string.Format(Texts.RemoveBug, steamId, response.StatusCode);
                case FriendResponseRelationship.Banned:
                    return string.Format(Texts.InBlackList, steamId);
                case FriendResponseRelationship.Recipient:
                case FriendResponseRelationship.Friend:
                case FriendResponseRelationship.Initiator:
                    var ex = new Exception($"Twitch:{userName},steam:{steamId},relat:{response.Relationship},res:{response.StatusCode},status:{response.Status}");
                    LogRepository.Instance.LogException("DeleteSteamUserError", ex);
                    return string.Format(Texts.Wtf, steamId);
                default:
                    throw new ArgumentOutOfRangeException(nameof(response), response, null);
            }
        }
Пример #2
0
        private static string HandleAddResponse(FriendResponseContainer response, long steamId, string userName, string chatName)
        {
            switch (response.Status)
            {
                case FriendResponseStatus.Added:
                case FriendResponseStatus.Removed:
                case FriendResponseStatus.AlreadyAdded:
                case FriendResponseStatus.CantRemove:
                    break;
                case FriendResponseStatus.Error:
                {
                    if(response.StatusCode == 41) // Ignored = 41
                        return string.Format(Texts.AddBugAfterDelete, steamId);

                    return string.Format(Texts.AddBug, steamId, response.StatusCode);
                }
                case FriendResponseStatus.NotInFriends:
                    return string.Format(Texts.NotInFriends, steamId, response.Relationship);
                default:
                    throw new ArgumentOutOfRangeException(nameof(response.Status), response.Status, null);
            }

            switch (response.Relationship)
            {
                case FriendResponseRelationship.None:
                case FriendResponseRelationship.Error:
                    return string.Format(Texts.AddBug, steamId, response.StatusCode);
                case FriendResponseRelationship.Banned:
                    return string.Format(Texts.InBlackList, steamId);
                case FriendResponseRelationship.Recipient:
                    return string.Format(Texts.AlreadyInRequest, steamId);
                case FriendResponseRelationship.Friend:
                    ChatterInfoRepository.Instance.AddChatterSteamId(userName, chatName, steamId);
                    return string.Format(Texts.AlreadyInFriends, steamId);
                case FriendResponseRelationship.Initiator:
                {
                    ChatterInfoRepository.Instance.AddChatterSteamId(userName, chatName, steamId);

                    if (response.Status == FriendResponseStatus.AlreadyAdded)
                        return string.Format(Texts.AlreadyNeedConfirm, steamId);

                    return string.Format(Texts.NeedConfirm, steamId);
                }
                default:
                    throw new ArgumentOutOfRangeException(nameof(response), response, null);
            }
        }