Пример #1
0
        public void HandleUserMessage(ITelegramUserMessage message)
        {
            if (message.IsEmpty())
            {
                return;
            }

            ISessionManager sessionManager = ModulesManager.GetModulesManager().GetSessionManager();

            IChatSession chatSession = sessionManager.GetChatSession(message.ChatId);

            if (chatSession == null)
            {
                sessionManager.CreateChatSession(message.ChatId);
                chatSession = sessionManager.GetChatSession(message.ChatId);
            }

            sessionManager.UserSentMessage(message.ChatId, message.MessageId);
            if (string.Equals(message.Message, "/e") || string.Equals(message.Message, "/exit"))
            {
                sessionManager.KillChatSession(message.ChatId);
            }
            else
            {
                chatStateHandlerFactory.GetChatStateHandler(chatSession.State).HandleUserMessage(message, this);
            }
        }