|
@@ -1,30 +1,15 @@
|
|
|
-using System.Linq;
|
|
|
using System.Threading.Tasks;
|
|
|
-using Telegram.Bot;
|
|
|
using Telegram.Bot.Types;
|
|
|
|
|
|
namespace MafiaTelegramBot.Models.Commands
|
|
|
{
|
|
|
- public abstract class Command
|
|
|
+ public abstract class Command : UpdateModel
|
|
|
{
|
|
|
- protected abstract string Name { get; }
|
|
|
-
|
|
|
- protected abstract Task<Message> Execute(Update update, TelegramBotClient client);
|
|
|
-
|
|
|
- private bool Contains(string command)
|
|
|
- {
|
|
|
- return command.Contains(Name);
|
|
|
- }
|
|
|
-
|
|
|
public static Task Update(Update update)
|
|
|
{
|
|
|
var commands = Bot.Commands;
|
|
|
var message = update.Message.Text;
|
|
|
- var client = Bot.Get();
|
|
|
-
|
|
|
- return (from command in commands
|
|
|
- where command.Contains(message)
|
|
|
- select command.Execute(update, client)).FirstOrDefault();
|
|
|
+ return FirstOrDefault(commands, message).Execute(update);
|
|
|
}
|
|
|
}
|
|
|
}
|