-
Notifications
You must be signed in to change notification settings - Fork 42
Home
Jammerware edited this page May 1, 2015
·
21 revisions
MargieBot is a very simple bot framework for Slack, one of the coolest free chat and collaboration web applications in the history of time. MargieBot is written in C#.NET, and it's designed to make creating bots for Slack accessible to anyone who knows a little C# or VB and has a vision for fun and/or helpful bot interactions.
MargieBot is designed to be easy to understand, quick to get started with, and fun to use.
Bot myBot = new Bot("<your bot's slack API token>");
myBot.MessageReceived += (string message) => { Console.Debug.WriteLine(message); };
If you can write it in C# or VB, MargieBot can bring it to life in Slack. Want to call a coworker a scruffy-looking nerf-herder every time he says the phrase "technical debt" in a public channel, but only if it's at the bottom of the hour? MargieBot has your back.
public class TechDebtResponseProcessor : IResponseProcessor
{
public bool CanRespond(MargieContext context)
{
return
Regex.IsMatch(context.Message.Text, "\btechnical debt\b") &&
context.UserNameCache[context.Message.User] == "obnoxious coworker" &&
DateTime.Now.Minute > 30;
}
public string GetResponse(MargieContext context)
{
return "God, " + context.Message.FormattedUser + ", you're such a scruffy-looking nerf-herder.";
}
public bool ResponseRequiresBotMention(MargieContext context)
{
return false;
}
}
myBot.ResponseProcessors.Add(new TechDebtResponseProcessor());