public static async Task Create(BotService bot, SlackChannel channel, string taskName, Func <Task> task) { var slack = bot.Slack; var msg = await slack.SendMessage(channel.Id, $"{taskName}..."); try { await Task.Run(task); await msg.Update($":ballot_box_with_check: {taskName} SUCCESS"); } catch (Exception e) { await msg.Update($":ballot_box_with_check: {taskName} FAILURE"); Console.WriteLine(e); } }
public static void RegisterCommand(string pattern, SubscribeTarget target, BotService inst, MethodInfo method) { if (string.IsNullOrEmpty(pattern)) { throw new ArgumentException(nameof(pattern)); } if (method == null) { throw new ArgumentNullException(nameof(method)); } var regex = new Regex(pattern); RegisterHandler(new SlackMessageHandler() { Pattern = regex, Target = target, ServiceInstance = inst, Handler = method }); }