using TelegramBotBase.Base; using TelegramBotBase.Form; namespace TelegramBotBase.Experiments.ActionManager.Actions { public class StringAction : IExternalAction { public string Method { get; set; } String? _lastValue { get; set; } Func Action; public StringAction(string method, Func action) { Method = method; Action = action; } public bool DoesFit(string raw_data) { var cd = CallbackData.Deserialize(raw_data); if (cd == null) return false; if (cd.Method != Method) return false; _lastValue = cd.Value; return true; } public async Task DoAction(UpdateResult ur, MessageResult mr) => await Action(_lastValue, ur, mr); public static CallbackData GetCallback(string method, long l) => new CallbackData(method, l.ToString()); } public class StringAction : IExternalAction where TForm : FormBase { public string Method { get; set; } String? _lastValue { get; set; } Func Action; public StringAction(string method, Func action) { Method = method; Action = action; } public bool DoesFit(string raw_data) { var cd = CallbackData.Deserialize(raw_data); if (cd == null) return false; if (cd.Method != Method) return false; _lastValue = cd.Value; return true; } public async Task DoAction(UpdateResult ur, MessageResult mr) => await Action(_lastValue, ur, mr); } }