Skip to content
shiftkey edited this page Jan 10, 2012 · 4 revisions

Want to start writing your own extensions to JibbR?

Three steps:

  • Create a new project under the Extensions folder - name it whatever you want

  • Create a class which implements one of the extension points - the ICommandSprocket or IAnnounce interface are currently supported

TODO: ICommandSprocket sample

[Export(typeof(IAnnounce))]
public class EchoAnnouncement : IAnnounce
{
    public TimeSpan Interval
    {
        get { return TimeSpan.FromMinutes(5); }
    }

    public void Execute(Bot bot)
    {
        // TODO: something smarter
        foreach (var room in bot.Rooms)
        {
            bot.Say("Hello world!", room);
        }
    }
}

Note how we have the Export attribute at the top of the class? We're using MEF to wire up components at runtime. You don't need to modify the console runner code to add your extension.

  • Add the project to the Jabbot.ConsoleBotHost/get-packages.cmd script to copy the project assemblies after building the solution:

    @echo off set solution=%1

    cp %solution%/Extensions/SampleAnnouncement/bin/Debug/.dll %solution%/Jabbot.ConsoleBotHost/bin/Debug/Sprockets/ cp %solution%/Extensions/SampleSprocket/bin/Debug/.dll %solution%/Jabbot.ConsoleBotHost/bin/Debug/Sprockets/ cp %solution%/Extensions/MyExtension/bin/Debug/*.dll %solution%/Jabbot.ConsoleBotHost/bin/Debug/Sprockets/

And that's it.

Clone this wiki locally