[store] disable store command for bots, cleanup

This commit is contained in:
West14
2022-05-10 19:11:01 +03:00
parent 0aea2fac42
commit 2bffddd57c
2 changed files with 7 additions and 5 deletions
+1 -3
View File
@@ -1,8 +1,6 @@
using System.Reflection; using Kruzya.TelegramBot.Core;
using Kruzya.TelegramBot.Core;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using West.TelegramBot.ContentStore.Service; using West.TelegramBot.ContentStore.Service;
using Module = Kruzya.TelegramBot.Core.Module;
namespace West.TelegramBot.ContentStore; namespace West.TelegramBot.ContentStore;
+6 -2
View File
@@ -10,7 +10,6 @@ using Telegram.Bot;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.InputFiles; using Telegram.Bot.Types.InputFiles;
using Telegram.Bot.Types.ReplyMarkups; using Telegram.Bot.Types.ReplyMarkups;
using West.TelegramBot.ContentStore.Model;
using West.TelegramBot.ContentStore.Service; using West.TelegramBot.ContentStore.Service;
namespace West.TelegramBot.ContentStore.Handler; namespace West.TelegramBot.ContentStore.Handler;
@@ -31,6 +30,11 @@ public class Store : BotEventHandler
[Command(InChat.Public, "store", CommandParseMode.Both)] [Command(InChat.Public, "store", CommandParseMode.Both)]
public async Task HandleStore() public async Task HandleStore()
{ {
if (From.IsBot)
{
return;
}
if (_reputation == null) if (_reputation == null)
{ {
await Bot.SendTextMessageAsync(Chat.Id, "Reputation is unavailable."); await Bot.SendTextMessageAsync(Chat.Id, "Reputation is unavailable.");
@@ -85,7 +89,7 @@ public class Store : BotEventHandler
return; return;
} }
var storeItem = mediaService.StoreItem; var storeItem = mediaService!.StoreItem;
var messageId = query.Message!.MessageId; var messageId = query.Message!.MessageId;
var reputation = await _reputation.GetUserReputationAsync(Chat, From); var reputation = await _reputation.GetUserReputationAsync(Chat, From);
if (reputation < storeItem.Price) if (reputation < storeItem.Price)