/// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void InternalHandle(object sender, CallbackQueryEventArgs e)
        {
            TelegramBotMessageManager.Message.Value = e.CallbackQuery.Message;

            var userService = TelegramBotServicesContainer.GetService <ITelegramBotUserService>();
            var currentUser = userService.GetCurrentUserInfo();

            if (currentUser == null)
            {
                currentUser = userService.RegisterUser();
            }

            TelegramBotLanguageHelper.InitializeCulture(currentUser.Language);
            var commandId = GetCommandId(e.CallbackQuery.Data);

            if (commandId == null)
            {
                return;
            }

            var command = TelegramBotCommandFactory.GetCallbackCommand(commandId.Value);

            if (command == null)
            {
                return;
            }

            e.CallbackQuery.Data = RemoveCommandId(e.CallbackQuery.Data);
            TelegramBotCallbackQueryManager.CallbackQuery.Value = e.CallbackQuery;
            command.Execute();
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected virtual string GetNameWithAttribute()
        {
            var userService = TelegramBotServicesContainer.GetService <ITelegramBotUserService>();
            var currentUser = userService.GetCurrentUserInfo();

            if (string.IsNullOrEmpty(currentUser?.Language))
            {
                return(Names.FirstOrDefault().Value);
            }

            if (Names.ContainsKey(currentUser.Language))
            {
                return(Names[currentUser.Language]);
            }

            return(Names.FirstOrDefault().Value);
        }