Beispiel #1
0
        public async Task <List <string> > FindSecretGroups()
        {
            SecretGroups = await FileMaster.ReadAndDeserialize <string>
                               (Path.Combine(messenger.Server.UsersPath, Nick, "secretGroups.json"));

            return(SecretGroups);
        }
Beispiel #2
0
        public async Task Run(string nick, bool needChangeMessages)
        {
            userNickname = nick;
            await DeleteData(messenger.Server.PublicGroupPath,
                             await FileMaster.ReadAndDeserialize <string>(Path.Combine(messenger.Server.UsersPath, userNickname, "userGroups.json")),
                             await FileMaster.ReadAndDeserialize <string>(Path.Combine(messenger.Server.UsersPath, userNickname, "leavedUserGroups.json")),
                             "ug",
                             needChangeMessages);

            await DeleteData(messenger.Server.SecretGroupPath,
                             await FileMaster.ReadAndDeserialize <string>(Path.Combine(messenger.Server.UsersPath, userNickname, "secretGroups.json")),
                             await FileMaster.ReadAndDeserialize <string>(Path.Combine(messenger.Server.UsersPath, userNickname, "leavedSecretGroups.json")),
                             "sg",
                             needChangeMessages);
            await DeleteData(messenger.Server.PeopleChatsPath,
                             ((await FileMaster.ReadAndDeserialize <PersonChat>(Path.Combine(messenger.Server.UsersPath, userNickname, "peopleChatsBeen.json")))
                              ?? new List <PersonChat>()).Select(chat => chat.NameChat).ToList(),
                             ((await FileMaster.ReadAndDeserialize <PersonChat>(Path.Combine(messenger.Server.UsersPath, userNickname, "leavedPeopleChatsBeen.json")))
                              ?? new List <PersonChat>()).Select(chat => chat.NameChat).ToList(),
                             "pp",
                             needChangeMessages);
            await DeleteInvitations();

            //fileMaster.DeleterFolder($"{Users}\\{user}");
        }
Beispiel #3
0
 private async Task <bool> CheckPerson(string namePerson)
 {
     return(((await FileMaster.ReadAndDeserialize <UserNicknameAndPasswordAndIPs>(Path.Combine(messenger.Server.NicknamesAndPasswordsPath, "users.json")))
             ?? new List <UserNicknameAndPasswordAndIPs>())
            .Select(user => user.Nickname)
            .Contains(namePerson));
 }
Beispiel #4
0
        public async Task <List <string> > FindInvitations()
        {
            Invitations = await FileMaster.ReadAndDeserialize <string>
                              (Path.Combine(messenger.Server.UsersPath, Nick, "invitation.json"));

            return(Invitations);
        }
Beispiel #5
0
 private async Task <List <string> > FindChatsPeople()
 {
     return(((await FileMaster.ReadAndDeserialize <UserNicknameAndPasswordAndIPs>(Path.Combine(messenger.Server.NicknamesAndPasswordsPath, "users.json")))
             ?? new List <UserNicknameAndPasswordAndIPs>())
            .Select(user => user.Nickname)
            .Where(nickname => nickname != user.Nickname)
            .ToList());
 }
Beispiel #6
0
 public async Task <List <string> > FindChatsWithPeople()
 {
     ChatsWithPeople = ((await FileMaster.ReadAndDeserialize <PersonChat>
                             (Path.Combine(messenger.Server.UsersPath, Nick, "peopleChatsBeen.json")))
                        ?? new List <PersonChat>())
                       .Select(chat => chat.Nicknames[0] != Nick ? chat.Nicknames[0] : chat.Nicknames[1])
                       .ToList();
     return(ChatsWithPeople);
 }
        private async Task <bool> CheckBans(UserNicknameAndPasswordAndIPs user)
        {
            var banUsers = await FileMaster.ReadAndDeserialize <string>(Path.Combine(messenger.Server.BansPath, "nicknamesBun.json"));

            if (banUsers == null)
            {
                return(false);
            }
            return(banUsers.Contains(user.Nickname));
        }
Beispiel #8
0
        public async Task <List <string> > FindAllElsePeople()
        {
            await FindChatsWithPeople();

            AllElsePeople = ((await FileMaster.ReadAndDeserialize <UserNicknameAndPasswordAndIPs>
                                  (Path.Combine(messenger.Server.NicknamesAndPasswordsPath, "users.json")))
                             ?? new List <UserNicknameAndPasswordAndIPs>())
                            .Select(x => x.Nickname)
                            .Where(x => x != Nick)
                            .Except(ChatsWithPeople)
                            .ToList();
            return(AllElsePeople);
        }
Beispiel #9
0
 private async Task<bool> CheckNicknamesBan(string nick)
 {
     var nicksBan = await FileMaster.ReadAndDeserialize<string>(Path.Combine(messenger.Server.BansPath, "nicknamesBun.json"));
     if (nicksBan != null)
     {
         foreach (var nickBan in nicksBan)
         {
             if (nick == nickBan)
             {
                 return true;
             }
         }
     }
     return false;
 }
Beispiel #10
0
 private async Task<bool> CheckIPsBan()
 {
     var path = Path.Combine(messenger.Server.BansPath, "IPsBun.json");
     var IPsBan = await FileMaster.ReadAndDeserialize<string>(path);
     if (IPsBan != null)
     {
         foreach (var IPBan in IPsBan)
         {
             if (IP == IPBan)
             {
                 await communication.SendMessage("Your IP is in ban, bye");
                 return true;
             }
         }
     }
     return false;
 }
Beispiel #11
0
        private async Task <bool> CheckUserPresenceGroup(string namePerson, User user)
        {
            if (!await CheckUsersLeavedPeopleInvitation(Path.Combine(PathChat, "leavedPeople.json")))
            {
                if (!await CheckUsersLeavedPeopleInvitation(Path.Combine(PathChat, "users.json")))
                {
                    if (!await CheckUsersLeavedPeopleInvitation(Path.Combine(PathChat, "invitation.json")))
                    {
                        return(false);
                    }
                    ;
                    await user.communication.SendMessage("This person has an invitation");

                    //await SendMessageAndAddUser("This person has an invitation", user);
                    return(true);
                }
                ;
                await user.communication.SendMessage("This person is in the group");

                //await SendMessageAndAddUser("This person is in the group", user);
                return(true);
            }
            ;
            await user.communication.SendMessage("This person leaved the group");

            //await SendMessageAndAddUser("This person leaved the group", user);
            return(true);

            async Task <bool> CheckUsersLeavedPeopleInvitation(string path)
            {
                var users = await FileMaster.ReadAndDeserialize <string>(path);

                if (users == null)
                {
                    return(false);
                }
                return(users.Contains(namePerson));
                //return ((await fileMaster.ReadAndDesToLString(path))
                //    ?? new List<string>())
                //    .Contains(namePerson);
            }
        }
Beispiel #12
0
 private async Task<IEnumerable<UserNicknameAndPasswordAndIPs>> TakeAllUserData()
 {
     return await FileMaster.ReadAndDeserialize<UserNicknameAndPasswordAndIPs>(FilePath);
 }
Beispiel #13
0
 public async Task <List <PersonChat> > FindPersonChats()
 {
     return((await FileMaster.ReadAndDeserialize <PersonChat>
                 (Path.Combine(messenger.Server.UsersPath, Nick, "peopleChatsBeen.json")))
            ?? new List <PersonChat>());
 }