public async Task UpdateHandle(Update update)
        {
            if (update.Type == UpdateType.Message || update.Type == UpdateType.CallbackQuery)
            {
                var chatId = _updateHelper.GetChatId(update);

                if (!_users.UserInfo.ContainsKey(chatId))
                {
                    _users.UserInfo.Add(chatId, new UserInfo()
                    {
                        UserName = _updateHelper.GetUserName(update)
                    });
                    _logHelper.Log("L5NB54645KJJKEW2", $"MENU LOADER TYPE: {_menuLoader.MenuLoaderType}", LogLevel.Information);

                    if (_menuLoader.MenuLoaderType == "SimpleButtonMenuLoader")
                    {
                        await _menuLoader.LoadStateMenu(chatId, UserState.InSimpleMainMenu);
                    }
                    else
                    {
                        await _menuLoader.LoadStateMenu(chatId, UserState.InMainMenu);
                    }
                }
                else
                {
                    if (_menuLoader.MenuLoaderType == "SimpleButtonMenuLoader")
                    {
                        if (update.Type == UpdateType.Message)
                        {
                            _notificationRouter.RouteNotification(new NotificationItem(chatId, NotificationType.Remove, update.Message.MessageId.ToString()));
                            try
                            {
                                _room.DequeueId(chatId);
                            }
                            catch (Exception)
                            {
                            }
                            await _menuLoader.LoadStateMenu(chatId, UserState.InSimpleMainMenu);
                        }
                        else
                        {
                            _sessionRouter.RouteUpdate(update);
                        }
                    }
                    else
                    {
                        _sessionRouter.RouteUpdate(update);
                    }
                }
            }
            else
            {
                return;
            }
        }
        public async Task <IActionResult> Post([FromBody] Update update)
        {
            long chatId = _updateHelper.GetChatId(update);


            try
            {
                await _updateService.UpdateHandle(update);
            }
            catch (Exception ex)
            {
                _logHelper.Log("LKJ4L3K54343V3V43", ex.Message, LogLevel.Error);

                if (update.Message.Text != null)
                {
                    _logHelper.Log("DFD3S5F6DJLK6L458F", $"Crush report: message: {update.Message.Text}; userState: {_users.UserInfo[chatId].State}", chatId, LogLevel.Critical);
                    //_logger.LogInformation($"CODE LABEL: DFD3S5F6DS8F; Crush report: chatId: {chatId}; message: {update.Message.Text}; userState: {_users.UserInfo[chatId].State}", chatId);
                }
                else
                {
                    _logHelper.Log("KJKL4645LK645V6F45DFD", $"Crush report: userState: {_users.UserInfo[chatId].State}", chatId, LogLevel.Critical);
                    //_logger.LogInformation($"CODE LABEL: DFD3S5F6DS8F; Crush report: chatId: {chatId}; userState: {_users.UserInfo[chatId].State}", chatId);
                }

                _room.QueueFlush();

                var users = _users.UserInfo.Keys;
                foreach (var user in users)
                {
                    if (_menuLoader.MenuLoaderType == "SimpleButtonMenuLoader")
                    {
                        await _menuLoader.LoadStateMenu(chatId, UserState.InSimpleMainMenu);
                    }
                    else
                    {
                        await _menuLoader.LoadStateMenu(chatId, UserState.InMainMenu);
                    }
                }
                return(Ok());
            }
            return(Ok());
        }
Example #3
0
        private UserState GetStatus(Update update)
        {
            long chatId = _updateHelper.GetChatId(update);

            return(_users.UserInfo[chatId].State);
        }