private async Task <string> SelectGroupName(string typeGroup) { await SendMessage("Enter a group name"); while (true) { var groupName = await user.communication.ListenClient(); if (!CharacterCheckers.CheckInput(groupName)) { await SendMessage("The group name can only contain lowercase letters and numbers"); } else if (groupName.Length == 0) { await SendMessage("Group name length can't be 0"); } else if (CheckGroups(groupName, typeGroup)) { await SendMessage("A group with this name has already been created, enter new plese"); } else { return(groupName); } } }
private async Task<string> CheckNickname(string nick) { var lastString = ""; for (int i = 10; i > 0; i--) { lastString = $"{Environment.NewLine}a number of attempts left = {i - 1}"; if (nick.Length <= 5) { await communication.SendMessage(CreateMessage($"Enter nickname bigger than 5 symbols {lastString}", i)); } else { var goodInput = CharacterCheckers.CheckInput(nick); if (goodInput) { if (!await CheckNicknamesBan(nick)) { if (!CheckNicknamesOnline(nick)) { return nick; } else { await communication.SendMessage(CreateMessage($"This nickname is online, write else {lastString}", i)); } } else { await communication.SendMessage(CreateMessage($"This nickname is in ban, write else {lastString}", i)); } } else { await communication.SendMessage(CreateMessage($"The nickname can only contain lowercase letters and numbers {lastString}", i)); } } if (i != 1) { nick = await communication.ListenClient(); } } return ""; }