Plugins can also add custom components to the macro builder. Regular plugin api functions can be used within the Execute method. This page describes how to make a plugin that registers new components.
PluginCore.cs
[Plugin(1,"Extra Macro Component Plugin","Adds new macro components to the macro builder!")]publicclassPluginCore:IStartPlugin{ /// <summary> /// Should be used to check compatability with the /// current version of the bot. /// </summary>publicoverridevoidOnLoad(int version,int subversion,int buildversion) { }publicoverridePluginResponseOnEnable(IBotSettings botSettings) {/* Regular plugin content */return base.OnEnable(botSettings); }}publicclassTestMacroComponent:IExternalMacroComponent {publicTestMacroComponent() {this.Category=MacroComponentCategory.Misc;this.Outputs=newIMacroOutputCollection( new KeyValuePair<string, ExternalMacroOutput>("success", new ExternalMacroOutput("Success", "This output gets called once the call finishes", true)),
new KeyValuePair<string, ExternalMacroOutput>("output_internal_name", new ExternalMacroOutput("Error", "This output will never get called", false))
);this.Variables=newIMacroVariableCollection( new KeyValuePair<string, ExternalMacroVariable>("variable_internal_name1", new ExternalMacroVariable(typeof(string), "Message", "What message should we send to chat?", "my default message!"))
); }publicoverridestringGetName() {return"Test macro component"; }publicoverridestringGetInternalName() {return"ex:test_macro_component"; }publicoverridestringGetDescription() {return"This is a test macro component"; }publicoverridestringGetInteractiveDescription() {var variableValue =GetVariable<string>("variable_internal_name1");returnstring.IsNullOrWhiteSpace(variableValue) ?GetDescription() :$"I will say {variableValue}."; }publicoverridestringExecute(IBotContext Context) {Context.Functions.Chat("My message: "+GetVariable<string>("variable_internal_name1"));return"success"; // or return "output_internal_name" }}
Outputs
Outputs refer to possible paths that the macro component will lead to. The execute method should return a name of one of the registered outputs. These should be registered in the constructor, as can be seen here:
publicTestMacroComponent() {...this.Outputs=newIMacroOutputCollection( new KeyValuePair<string, ExternalMacroOutput>("success", new ExternalMacroOutput("Success", "This output gets called once the call finishes", true)),
new KeyValuePair<string, ExternalMacroOutput>("output_internal_name", new ExternalMacroOutput("Error", "This output will never get called", false))
);...}