-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
The configuration for NBot can be done through the Create method on the Robot class. This will start a method chain of registrations of the following elements of NBot.
It is best to create your brain before you start using the fluent interface as some of the other registrations may require a brain to be registered. See Example.
var brain = new FileBrain(".\\Brain");
Robot.Create("NBot")
.UseBrain(brain)
You are not required to register any message filters, but they can be handy. So I recommend that you install the HandleBarsMessageFilter. This will allow you to use stored values in the brain to replace values in your messages. See Example.
var brain = new FileBrain(".\\Brain");
Robot.Create("NBot")
.UseBrain(brain)
.RegisterMessageFilter(new HandleBarsMessageFilter(brain))
For NBot to have a way of receiving and sending messages he requires at least one Adapter. Currently there is the console adapter (For Testing) and the Campfire Adapter for interfacing with Campfire. See Examples.
var brain = new FileBrain(".\\Brain");
Robot.Create("NBot")
.UseBrain(brain)
.RegisterMessageFilter(new HandleBarsMessageFilter(brain))
.RegisterAdapter(new ConsoleAdapter(), "ConsoleChannel")
With the campfire adapter you will have to provide your authorization token, your campfire sub domain as well as a list of rooms to join.
var brain = new FileBrain(".\\Brain");
Robot.Create("NBot")
.UseBrain(brain)
.RegisterMessageFilter(new HandleBarsMessageFilter(brain))
.RegisterAdapter(new CampfireAdapter.CampfireAdapter("AUTH_TOKEN", "SUB_DOMAIN",
1234,
5678,
9101112,
12141516
), "Campfire")
Handlers can be registered in one or more of many ways. You are not required to register any handlers, but what good is the help handler with no handlers to provide help for? You can also specify what rooms that the handlers are allowed in.
For individual registration this is fairly simple just call RegisterHandler and supply it with an instance of your handler. NBot will take care of the rest. When you use this method you can also supply a list of rooms that this handler will be allowed in. If none is supplied then it is registered in all rooms.
var brain = new FileBrain(".\\Brain");
Robot.Create("NBot")
.UseBrain(brain)
.RegisterMessageFilter(new HandleBarsMessageFilter(brain))
.RegisterAdapter(new ConsoleAdapter(), "ConsoleChannel")
.RegisterHandler(new Achievement())
This will allow you to register all of the handlers in a given assembly. Using this method you can call another method to specify what rooms that this plugin will be allowed in. Either AllowedInAllRooms() or AllowedInRooms(123,234,345,234) which will restrict the number of rooms that the handlers are allowed in.
var brain = new FileBrain(".\\Brain");
Robot.Create("NBot")
.UseBrain(brain)
.RegisterMessageFilter(new HandleBarsMessageFilter(brain))
.RegisterAdapter(new ConsoleAdapter(), "ConsoleChannel")
.RegisterHandlersInAssembly(Assembly.Load("NBot.MessageHandlers"))
.AllowedInAllRooms()
This method will allow you to break up the room selection by specifying a set of tags that the handlers have to be allowed in given rooms. This will allow you to, for example, only allow your "Fun" plugins in a single room where your "Productivity" plugins can be in all rooms. It is an extension of the Assembly Registration section. The tags are supplied via an attribute on the handler class.
var brain = new FileBrain(".\\Brain");
Robot.Create("NBot")
.UseBrain(brain)
.RegisterMessageFilter(new HandleBarsMessageFilter(brain))
.RegisterAdapter(new ConsoleAdapter(), "ConsoleChannel")
.RegisterHandlersInAssembly(Assembly.Load("NBot.MessageHandlers"),"Fun")-- < Supply Some Tags
.AllowedInAllRooms()
Currently there is only the console logger, but there are more coming soon. For the Console Logger there is no need to register as it is the default. If you have written an implementation of the INBotLog interface for your favorite Logger please feel free to register it using the UseLog method. Something like the following code.
INBotLog log = new Log4NetLog(LogManager.GetLogger("MyLogger"));
var brain = new FileBrain(".\\Brain");
Robot.Create("NBot")
.UseBrain(brain)
.UseLog(log)