ShowTradersInBotChat.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. using System.Threading.Tasks;
  2. using CardCollector.Controllers;
  3. using CardCollector.DataBase.Entity;
  4. using CardCollector.Resources;
  5. using CardCollector.Session.Modules;
  6. using Telegram.Bot.Types;
  7. using Telegram.Bot.Types.Enums;
  8. namespace CardCollector.Commands.InlineQuery
  9. {
  10. public class ShowTradersInBotChat : InlineQueryCommand
  11. {
  12. public override async Task Execute()
  13. {
  14. var module = User.Session.GetModule<AuctionModule>();
  15. // Получаем список продавцов
  16. var traders = await AuctionController.GetTradersList(Query, module.SelectedSticker.Id);
  17. var results = User.Session.GetModule<FiltersModule>()
  18. .ApplyPriceTo(traders)
  19. .ToTelegramResults(Command.buy_sticker, 1.0 - await User.AuctionDiscount()/100.0);
  20. // Посылаем пользователю ответ на его запрос
  21. await MessageController.AnswerInlineQuery(InlineQueryId, await results);
  22. }
  23. protected internal override bool IsMatches(UserEntity user, Update update)
  24. {
  25. return update.InlineQuery?.ChatType is ChatType.Sender && user.Session.State == UserState.ProductMenu;
  26. }
  27. public ShowTradersInBotChat() { }
  28. public ShowTradersInBotChat(UserEntity user, Update update) : base(user, update) { }
  29. }
  30. }