Ejemplo n.º 1
0
        public bool TryHandle(SlackBotCommandContext context, CancellationToken token, out Task task)
        {
            task = null;

            string taskName = context.IncomingMessage.Text;

            ITask taskToExecute;

            if (!string.IsNullOrWhiteSpace(taskName) && _factory.TryGet(taskName, out taskToExecute))
            {
                task = context.WriteText($"Task {taskToExecute.Name()} is being executed.")
                       .ContinueWith(t => Task.FromResult(_runner.Execute(taskToExecute)), token)
                       .ContinueWith(t => context.WriteText($"Task {taskToExecute.Name()} finished executing."), token);
            }

            return(task != null);
        }
Ejemplo n.º 2
0
        public bool TryHandle(SlackBotCommandContext context, CancellationToken token, out Task task)
        {
            task = null;

            if (!string.Equals(context.IncomingMessage.Text, "Ping", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }



            task = context.WriteText($"[{Environment.MachineName}{_postFix}]: I'm up and running, thanks. Uptime: {_uptime.UptimeText}.");

            return(true);
        }