IRCPluginImpl

Mixin that fully implements an IRCPlugin.

Uses compile-time introspection to call module-level functions to extend behaviour.

With UFCS, transparently emulates all such as being member methods of the mixing-in class.

mixin template IRCPluginImpl (
Flag!"debug_" debug_ = No.debug_
string module_ = __MODULE__
) {
version(unittest)
static if(!is(typeof(this) : IRCPlugin))
enum wrongThisPattern;
version(unittest)
static if(!is(typeof(this) : IRCPlugin))
enum wrongThisMessage;
}

Constructors

this
this(IRCPluginState state)

Basic constructor for a plugin.

Members

Functions

allow
FilterResult allow(IRCEvent event, Permissions permissionsRequired)

Judges whether an event may be triggered, based on the event itself and the annotated required Permissions of the handler in question. Wrapper function that merely calls kameloso.plugins.common.allowImpl. The point behind it is to make something that can be overridden and still allow it to call the original logic (below).

channelSpecificCommands
IRCPlugin.CommandMetadata[string] channelSpecificCommands(string channelName)

Compile a list of our a plugin's oneliner commands.

commands
IRCPlugin.CommandMetadata[string] commands()

Forwards to IRCPluginImpl.commandsImpl.

commandsImpl
auto commandsImpl()

Collects all IRCEventHandler.Command command words and IRCEventHandler.Regex regex expressions that this plugin offers at compile time, then at runtime returns them alongside their descriptions and their visibility, as an associative array of IRCPlugin.CommandMetadatas keyed by command name strings.

deserialiseConfigFrom
void deserialiseConfigFrom(string configFile, string[][string] missingEntries, string[][string] invalidEntries)

Loads configuration for this plugin from disk.

initResources
void initResources()

Writes plugin resources to disk, creating them if they don't exist.

isEnabled
bool isEnabled()

Introspects the current plugin, looking for a Settings-annotated struct member that has a bool annotated with Enabler, which denotes it as the bool that toggles a plugin on and off.

name
string name()

Returns the name of the plugin. (Technically it's the name of the module.)

onBusMessage
void onBusMessage(string header, Sendable content)

Proxies a bus message to the plugin, to let it handle it (or not).

onEvent
void onEvent(IRCEvent event)

Forwards the supplied IRCEvent to IRCPluginImpl.onEventImpl.

onEventImpl
void onEventImpl(IRCEvent origEvent)

Pass on the supplied IRCEvent to module-level functions annotated with an IRCEventHandler, registered with the matching IRCEvent.Types.

postprocess
void postprocess(IRCEvent event)

Lets a plugin modify an IRCEvent while it's begin constructed, before it's finalised and passed on to be handled.

printSettings
void printSettings()

Prints the plugin's Settings-annotated settings struct.

selftest
Ternary selftest(Selftester tester)

Self-test function.

serialiseConfigInto
bool serialiseConfigInto(Appender!(char[]) sink)

Gathers the configuration text the plugin wants to contribute to the configuration file.

setSettingByName
bool setSettingByName(string setting, string value)

Change a plugin's Settings-annotated settings struct member by their string name.

tick
bool tick(Duration elapsed)

Tick function. Called once every main loop iteration.

Manifest constants

hasIRCPluginImpl
enum hasIRCPluginImpl;

Flag denoting that IRCPluginImpl has been mixed in.

Structs

Introspection
struct Introspection

Namespace for the alias sequences of all event handler functions in this module, as well as the one of all IRCEventHandler annotations in the module.

Parameters

debug_

Enables some debug output.

module_

Name of the current module. Should never be specified and always be left to its __MODULE__ default value. Here be dragons.

Examples

final class MyPlugin : IRCPlugin
{
    MyPluginSettings myPluginSettings;  // type should be annotated @Settings at declaration

    // ...implementation...

    mixin IRCPluginImpl;
}

See Also