コード例 #1
0
        private void Logout(long chatId, IChatStateHandlerContext context)
        {
            IMessageManager messageManager = ModulesManager.GetMessageManager();
            IUserManager    userManager    = ModulesManager.GetUserManager();

            userManager.LogoutUser(chatId);
            messageManager.SendTextMessageAsync(chatId, TextResponse.Get(ResponseType.Logout), null);
            context.ChangeChatState(chatId, ChatSessionState.Start);
        }
コード例 #2
0
        public void Kill()
        {
            IMessageManager messageManager = ModulesManager.GetMessageManager();
            IUserManager    userManager    = ModulesManager.GetUserManager();

            List <int> copyBotMessagesId  = new List <int>(botMessagesId);
            List <int> copyUserMessagesId = new List <int>(userMessagesId);

            messageManager.DeleteListMessages(ChatId, copyBotMessagesId);
            messageManager.DeleteListMessages(ChatId, copyUserMessagesId);
            userManager.LogoutUser(ChatId);
        }
コード例 #3
0
        private void RegistrationUser(ITelegramUserMessage message, IChatStateHandlerContext context)
        {
            IMessageManager messageManager = ModulesManager.GetMessageManager();
            IUserManager    userManager    = ModulesManager.GetUserManager();

            messageManager.DeleteMessage(message.ChatId, message.MessageId);

            if (CheckPassword(message.ChatId, message.Message))
            {
                userManager.CreateNewUser(message.ChatId, message.Message);
                messageManager.SendTextMessageAsync(message.ChatId, TextResponse.Get(ResponseType.Success), null);
                context.ChangeChatState(message.ChatId, ChatSessionState.Start);
            }
        }
コード例 #4
0
        private void LoginUser(ITelegramUserMessage message, IChatStateHandlerContext context)
        {
            IMessageManager messageManager = ModulesManager.GetMessageManager();
            IUserManager    userManager    = ModulesManager.GetUserManager();

            messageManager.DeleteMessage(message.ChatId, message.MessageId);

            bool success = userManager.LoginUser(message.ChatId, message.Message);

            if (success)
            {
                messageManager.SendTextMessageAsync(message.ChatId, TextResponse.Get(ResponseType.Success), null);
                context.ChangeChatState(message.ChatId, ChatSessionState.Authorized);
            }
            else
            {
                messageManager.SendTextMessageAsync(message.ChatId, TextResponse.Get(ResponseType.FailAuthorisation), null);
            }
        }