/// <summary> /// /// </summary> /// <param name="command"></param> /// <param name="servicesProvider"></param> public TelegramBotCommandService(ITelegramBotCommand command, ITelegramBotServicesProvider servicesProvider) { Command = command; TelegramBotServicesProvider = servicesProvider; TelegramBotCommandFactory = servicesProvider.GetService <ITelegramBotCommandFactory>(); Info = TelegramBotCommandFactory.GetCommandInfo(command.GetType()); MessageService = TelegramBotServicesProvider.GetService <ITelegramBotMessageService>(); }
/// <summary> /// /// </summary> public virtual void RemovePriorityCommand <TCommand>(long chatId) where TCommand : ITelegramBotCommand { var user = TelegramBotDb.Users.FindOne(f => f.ChatId == chatId); if (user == null) { return; } var command = TelegramBotCommandFactory.GetCommandInfo(typeof(TCommand)); if (command == null) { return; } if (user.PriorityCommands == null) { return; } user.PriorityCommands.RemoveAll(r => r == command.CommandId); TelegramBotDb.Users.Update(user); }