public WhatDoBotLogMiddleware(IMiddleware next, ModelContext ctx) : base(next) { this.ctx = ctx; HandlerMappings = new[] { new HandlerMapping { MessageShouldTargetBot = true, ShouldContinueProcessing = false, VisibleInHelp = true, Description = "Ask me what stuff I've logged for you.", ValidHandles = StartsWithHandle.For(whc), EvaluatorFunc = Validate(WhatHappened) }, new HandlerMapping { MessageShouldTargetBot = true, ShouldContinueProcessing = false, VisibleInHelp = true, Description = "If you just tell me stuff, I'll log it for you.", ValidHandles = new[] { new AlwaysMatchHandle() }, EvaluatorFunc = Validate(Log) } }; }
public void should_return_false_when_message_doesnt_contains_text(string exactText, string message) { // given var handle = new StartsWithHandle(exactText); // when bool isMatch = handle.IsMatch(message); // then isMatch.ShouldBeFalse(); }
public void should_return_true_when_message_contains_text(string startsWith, string message) { // given var handle = new StartsWithHandle(startsWith); // when bool isMatch = handle.IsMatch(message); // then isMatch.ShouldBeTrue(); }
public CalculatorMiddleware(IMiddleware next) : base(next) { HandlerMappings = new[] { new HandlerMapping { ValidHandles = StartsWithHandle.For("calc "), Description = "Try calc [math expression]", EvaluatorFunc = Handle } }; }
public JokeMiddleware(IMiddleware next) : base(next) { HandlerMappings = new[] { new HandlerMapping { MessageShouldTargetBot = false, ValidHandles = StartsWithHandle.For("suchar", "żart", "dowcip", "kawał", "coś śmiesznego"), EvaluatorFunc = JokeHandler, ShouldContinueProcessing = false, } }; }
public PoemMiddleware(IMiddleware next) : base(next) { HandlerMappings = new[] { new HandlerMapping { MessageShouldTargetBot = false, ValidHandles = StartsWithHandle.For("wiersz"), EvaluatorFunc = PoemHandler, ShouldContinueProcessing = false, } }; }
public IncidentManagementMiddleware(IMiddleware next, IncidentManagementPlugin incidentManagementPlugin, ILog log) : base(next) { this.incidentManagementPlugin = incidentManagementPlugin; this.log = log; this.HandlerMappings = new[] { new HandlerMapping { ValidHandles = StartsWithHandle.For($"{Configuration.Prefix} new"), EvaluatorFunc = this.NewIncidentHandler, Description = $"Declares a new incident. {this.newIncidentHelpText}", VisibleInHelp = true }, new HandlerMapping { ValidHandles = ExactMatchHandle.For($"{Configuration.Prefix} resolve"), EvaluatorFunc = this.ResolveIncidentHandler, Description = $"Resolve the incident associated with current channel. {this.resolveIncidentHelpText}", VisibleInHelp = true }, new HandlerMapping { ValidHandles = StartsWithHandle.For($"{Configuration.Prefix} postmortem"), EvaluatorFunc = this.AddPostmortemLinkToIncidentHandler, Description = $"Adds the postmortem link to the incident associated with current channel. {this.postmortemIncidentHelpText}", VisibleInHelp = true }, new HandlerMapping { ValidHandles = ExactMatchHandle.For($"{Configuration.Prefix} close"), EvaluatorFunc = this.CloseIncidentHandler, Description = $"Close the incident associated with current channel. {this.closeIncidentHelpText}", VisibleInHelp = true }, new HandlerMapping { ValidHandles = ExactMatchHandle.For($"{Configuration.Prefix} list active"), EvaluatorFunc = this.ListActiveIncidentHandler, Description = $"Lists active incidents. {this.listActiveIncidentHelpText}", VisibleInHelp = true }, new HandlerMapping { ValidHandles = ExactMatchHandle.For($"{Configuration.Prefix} list recent"), EvaluatorFunc = this.ListRecentIncidentHandler, Description = $"Lists recent incidents. {this.listRecentIncidentHelpText}", VisibleInHelp = true }, }; }
public DnsMiddleware(IMiddleware next, DnsPlugin dnsPlugin, ILog log) : base(next) { this.dnsPlugin = dnsPlugin; this.log = log; this.HandlerMappings = new[] { new HandlerMapping { ValidHandles = StartsWithHandle.For($"{Configuration.CommandPrefix} {Lookup}"), EvaluatorFunc = this.DnsLookupHandler, Description = $"Gets IP address for dns entry. {GetHelpText(Lookup)}", VisibleInHelp = true }, }; }
public NewRelicMiddleware(IMiddleware next, NewRelicPlugin newRelicPlugin, ILog log) : base(next) { this.newRelicPlugin = newRelicPlugin; this.HandlerMappings = new[] { new HandlerMapping { ValidHandles = ExactMatchHandle.For($"{Configuration.CommandPrefix} applications"), EvaluatorFunc = this.ApplicationsHandler, Description = $"Gets applications summary from NewRelic. '{Configuration.CommandPrefix} applications'", VisibleInHelp = true }, new HandlerMapping { ValidHandles = ExactMatchHandle.For($"{Configuration.CommandPrefix} applications detail"), EvaluatorFunc = this.ApplicationsDetailHandler, Description = $"Gets applications detail from NewRelic. {Configuration.CommandPrefix} applications detail", VisibleInHelp = true }, new HandlerMapping { ValidHandles = ExactMatchHandle.For($"{Configuration.CommandPrefix} applications detail unhealthy"), EvaluatorFunc = this.UnhealthyApplicationsDetailHandler, Description = $"Gets applications detail from NewRelic which are unhealthy. `applications detail unhealthy`", VisibleInHelp = true }, new HandlerMapping { ValidHandles = StartsWithHandle.For($"{Configuration.CommandPrefix} application detail"), EvaluatorFunc = this.ApplicationDetailHandler, Description = $"Gets application detail for one or more applications from NewRelic. {this.applicationDetailHelpText}", VisibleInHelp = true }, new HandlerMapping { ValidHandles = StartsWithHandle.For($"{Configuration.CommandPrefix} application metrics"), EvaluatorFunc = this.ApplicationMetricsHandler, Description = $"Gets application metrics from NewRelic for the requested application id. {this.applicationMetricsHelpText}", VisibleInHelp = false }, }; }
public BeerMiddleware(IMiddleware next) : base(next) { HandlerMappings = new[] { new HandlerMapping { MessageShouldTargetBot = true, ValidHandles = StartsWithHandle.For("poleć"), EvaluatorFunc = RecommendBeerHandler, ShouldContinueProcessing = false, }, new HandlerMapping { MessageShouldTargetBot = true, ValidHandles = new IValidHandle[] { new AlwaysMatchHandle(), }, EvaluatorFunc = BeerHandler } }; }
public PearlOfWisdomMiddleware(IMiddleware next) : base(next) { HandlerMappings = new[] { new HandlerMapping { MessageShouldTargetBot = false, ValidHandles = StartsWithHandle.For("złota myśl", "cytat", "dowcip", "kawał", "coś śmiesznego"), EvaluatorFunc = PearlOfWisdomHandler, ShouldContinueProcessing = false, }, new HandlerMapping { MessageShouldTargetBot = false, ValidHandles = RegexHandle.For("zyg[munt|a|uś]"), EvaluatorFunc = PearlOfWisdomHandler, ShouldContinueProcessing = false, }, }; }
public ScheduleMiddleware(IMiddleware next, SchedulePlugin schedulePlugin) : base(next) { _schedulePlugin = schedulePlugin; HandlerMappings = new[] { new HandlerMapping { ValidHandles = StartsWithHandle.For("schedule hourly"), Description = "Schedule a command to execute every hour on the current channel. Usage: `@{bot} schedule hourly @{bot} tell me a joke`", EvaluatorFunc = HourlyHandler, }, new HandlerMapping { ValidHandles = StartsWithHandle.For("schedule daily"), Description = "Schedule a command to execute every day on the current channel. Usage: `@{bot} schedule daily @{bot} tell me a joke`", EvaluatorFunc = DayHandler, }, new HandlerMapping { ValidHandles = StartsWithHandle.For("schedule cronjob"), Description = "Schedule a cron job for this channel. Usage: `@{bot} schedule cronjob '0 15 10 * * ?' @{bot} tell me a joke`", EvaluatorFunc = CronHandler, }, new HandlerMapping { ValidHandles = ExactMatchHandle.For("schedule list"), Description = "List all schedules on the current channel", EvaluatorFunc = ListHandlerForChannel, }, new HandlerMapping { ValidHandles = StartsWithHandle.For("schedule delete"), Description = "Delete a schedule in this channel. You must enter a valid {guid}", EvaluatorFunc = DeleteHandlerForChannel, }, }; }
public CloudflareMiddleware(IMiddleware next, CloudflarePlugin cloudflarePlugin, ILog log) : base(next) { this.cloudflarePlugin = cloudflarePlugin; this.log = log; this.HandlerMappings = new[] { new HandlerMapping { ValidHandles = StartsWithHandle.For($"{Configuration.CommandPrefix} {Purge} tag"), EvaluatorFunc = this.PurgeCacheTag, Description = $"Purges Cloudflare cache for specified cache tag. {GetPurgeCacheTagHelpText()}", VisibleInHelp = true }, new HandlerMapping { ValidHandles = StartsWithHandle.For($"{Configuration.CommandPrefix} {Purge} zone"), EvaluatorFunc = this.PurgeZone, Description = $"Purges Cloudflare cache for specified zone. { GetPurgeZoneHelpText()}", VisibleInHelp = true } }; }