private bool CheckPassword(long chatId, string password) { IMessageManager messageManager = ModulesManager.GetModulesManager().GetMessageManager(); if (string.IsNullOrEmpty(password)) { messageManager.SendTextMessage(chatId, TextResponse.Get(ResponseType.PasswordEmpty)); return(false); } if (password.Length < 12) { messageManager.SendTextMessage(chatId, TextResponse.Get(ResponseType.PasswordMinLength)); return(false); } if (password.Length > 25) { messageManager.SendTextMessage(chatId, TextResponse.Get(ResponseType.PasswordMaxLength)); return(false); } if (!Regex.IsMatch(password, @"^[a-zA-Z0-9!""#$%&'()*+,-./:;<=>?@[\]^_`{|}~]+$")) { messageManager.SendTextMessage(chatId, TextResponse.Get(ResponseType.PasswordCharacters)); return(false); } return(true); }
private void Logout(long chatId, IChatStateHandlerContext context) { IMessageManager messageManager = ModulesManager.GetModulesManager().GetMessageManager(); IUserManager userManager = ModulesManager.GetModulesManager().GetUserManager(); userManager.LogoutUser(chatId); messageManager.SendTextMessage(chatId, TextResponse.Get(ResponseType.Logout)); context.ChangeChatState(chatId, Session.ChatSessionState.Start); }
private void RegistrationUser(ITelegramUserMessage message, IChatStateHandlerContext context) { IMessageManager messageManager = ModulesManager.GetModulesManager().GetMessageManager(); IUserManager userManager = ModulesManager.GetModulesManager().GetUserManager(); if (CheckPassword(message.ChatId, message.Message)) { userManager.CreateNewUser(message.ChatId, message.Message); messageManager.SendTextMessage(message.ChatId, TextResponse.Get(ResponseType.SuccessRegistration)); context.ChangeChatState(message.ChatId, Session.ChatSessionState.Start); } }
public void HandleUserMessage(ITelegramUserMessage message, IChatStateHandlerContext context) { if (message == null || context == null) { return; } IMessageManager messageManager = ModulesManager.GetModulesManager().GetMessageManager(); messageManager.SendTextMessage(message.ChatId, TextResponse.Get(ResponseType.WelcomeMessage)); context.ChangeChatState(message.ChatId, ChatSessionState.Start); }
private void LoginUser(ITelegramUserMessage message, IChatStateHandlerContext context) { IMessageManager messageManager = ModulesManager.GetModulesManager().GetMessageManager(); IUserManager userManager = ModulesManager.GetModulesManager().GetUserManager(); bool success = userManager.LoginUser(message.ChatId, message.Message); if (success) { messageManager.SendTextMessage(message.ChatId, TextResponse.Get(ResponseType.SuccessAuthorisation)); context.ChangeChatState(message.ChatId, Session.ChatSessionState.Authorized); } else { messageManager.SendTextMessage(message.ChatId, TextResponse.Get(ResponseType.FailAuthorisation)); } }
private void GetStash(long chatId, IChatStateHandlerContext context) { IDatabaseManager databaseManager = ModulesManager.GetDatabaseManager(); IMessageManager messageManager = ModulesManager.GetMessageManager(); IUser user = databaseManager.GetUser(chatId); if (user != null && user.IsAuthorized) { ICollection <IStashMessage> messagesFromStash = databaseManager.GetMessagesFromStash(chatId); if (messagesFromStash.Count == 0) { messageManager.SendTextMessageAsync(chatId, TextResponse.Get(ResponseType.EmptyStash), null); } else { foreach (IStashMessage stashMessage in messagesFromStash) { stashMessage.Decrypt(user); stashMessage.Send(); } } } }
public void StartStateMessage(long chatId) { IMessageManager messageManager = ModulesManager.GetModulesManager().GetMessageManager(); messageManager.SendTextMessage(chatId, TextResponse.Get(ResponseType.RegistrationReady)); }
public void Handle(long chatId) { IMessageManager messageManager = ModulesManager.GetMessageManager(); messageManager.SendTextMessageAsync(chatId, TextResponse.Get(ResponseType.FullStashError), null); }
private void Information(long chatId, IChatStateHandlerContext context) { IMessageManager messageManager = ModulesManager.GetMessageManager(); messageManager.SendTextMessageAsync(chatId, TextResponse.Get(ResponseType.Information), null); }
public void StartStateMessage(long chatId) { IMessageManager messageManager = ModulesManager.GetMessageManager(); messageManager.SendTextMessageAsync(chatId, TextResponse.Get(ResponseType.MainCommands), chatCommands.CreateReplyKeyboard()); }
public void StartStateMessage(long chatId) { IMessageManager messageManager = ModulesManager.GetModulesManager().GetMessageManager(); messageManager.SendTextMessage(chatId, TextResponse.Get(ResponseType.MainCommands)); }