38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using TelegramBotBase.Base;
|
|
using TelegramBotBase.Form;
|
|
|
|
namespace TelegramBotBase.Experiments.ActionManager.Actions
|
|
{
|
|
|
|
public class StartWithAction : IExternalAction
|
|
{
|
|
public string SearchForString { get; set; }
|
|
|
|
public Action<FormBase, string> SetProperty { get; set; }
|
|
|
|
Func<String, UpdateResult, MessageResult, Task> Action;
|
|
|
|
|
|
public StartWithAction(string searchFor, Func<String, UpdateResult, MessageResult, Task> action)
|
|
{
|
|
SearchForString = searchFor;
|
|
Action = action;
|
|
}
|
|
|
|
public bool DoesFit(string raw_data) => raw_data.StartsWith(SearchForString);
|
|
|
|
|
|
public async Task DoAction(UpdateResult ur, MessageResult mr) => await Action(mr.RawData, ur, mr);
|
|
|
|
}
|
|
|
|
public static class StartWithAction_Extensions
|
|
{
|
|
public static void AddStartsWithAction(this ExternalActionManager manager, string value, Func<String, UpdateResult, MessageResult, Task> action)
|
|
{
|
|
manager.Add(new StartWithAction(value, action));
|
|
}
|
|
}
|
|
|
|
}
|