/// <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(); }
/// <summary> /// /// </summary> public TelegramBotDefaultOptions() { var container = new TelegramBotServicesContainer(); Container = container; ServicesProvider = new TelegramBotServicesProvider(container); ServicesRegistrator = new TelegramBotServicesRegistrator(); }
/// <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); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public virtual void Handle(object sender, CallbackQueryEventArgs e) { TelegramBotServicesContainer.RequestBegin(); InternalHandle(sender, e); TelegramBotServicesContainer.RequestEnd(); }