kameloso.plugins.common

Contains the definition of an IRCPlugin and its ancillaries, as well as mixins to fully implement it.

Event handlers can then be module-level functions, annotated with IRCEvent.Types.

Modules

awareness
module kameloso.plugins.common.awareness

Awareness mixins, for plugins to mix in to extend behaviour and enjoy a considerable degree of automation.

misc
module kameloso.plugins.common.misc

The is not a plugin by itself but contains code common to all plugins, without which they will *not* function.

mixins
module kameloso.plugins.common.mixins

The section of kameloso.plugins.common that involves mixins.

scheduling
module kameloso.plugins.common.scheduling

The section of kameloso.plugins.common that deals with delaying executing of Fibers and delegates to a later point in time, and registering such to await a specific type of IRCEvent.

Members

Classes

DeferredActionImpl
class DeferredActionImpl(T)

Concrete implementation of a DeferredAction.

IRCPlugin
class IRCPlugin

Abstract IRC plugin class.

Enums

ChannelPolicy
enum ChannelPolicy

Whether an annotated function should be allowed to trigger on events in only home channels or in guest ones as well.

Enabler
enum Enabler

Annotation denoting that a variable enables and disables a plugin.

FilterResult
enum FilterResult

The tristate results from comparing a username with the admin or whitelist/elevated/operator/staff lists.

Permissions
enum Permissions

What level of permissions is needed to trigger an event handler.

PrefixPolicy
enum PrefixPolicy

In what way the contents of a IRCEvent must start (be "prefixed") for an annotated function to be allowed to trigger.

Settings
enum Settings

Annotation denoting that a struct variable or struct type is to be considered as housing settings for a plugin, and should thus be serialised and saved in the configuration file.

Timing
enum Timing

Declaration of what order event handler function should be given with respects to other functions in the same plugin module.

Functions

allowImpl
auto allowImpl(IRCPlugin plugin, IRCEvent event, Permissions permissionsRequired)

Judges whether an event may be triggered, based on the event itself and the annotated Permissions of the handler in question. Implementation function.

assertSaneStorageClasses
auto assertSaneStorageClasses(ParameterStorageClass storageClass, bool paramIsConst, bool inFiber, string module_, string typestring)

Asserts that a parameter storage class is not ref if inFiber, and neither ref nor out if not inFiber. To be run during CTFE.

defer
void defer(IRCPlugin plugin, CarryingFiber!T fiber, string context, string subcontext, string creator)

Instantiates a DeferredActionImpl in the guise of a DeferredAction with the implicit type T as payload and appends it to the passed IRCPlugin's deferredActions array.

defer
void defer(IRCPlugin plugin, void delegate() dg, string context, string subcontext, string creator)

Instantiates a DeferredActionImpl in the guise of a DeferredAction with the implicit type T as payload and appends it to the passed IRCPlugin's deferredActions array.

enqueue
void enqueue(Plugin plugin, IRCEvent event, Permissions permissionsRequired, bool inFiber, Fun fun, string caller)

Construct and enqueue a function replay in the plugin's queue of such.

filterSender
auto filterSender(IRCEvent event, Permissions permissionsRequired, bool preferHostmasks)

Decides if a sender meets a Permissions and is allowed to trigger an event handler, or if a WHOIS query is needed to be able to tell.

filterSenderImpl
auto filterSenderImpl(Permissions permissionsRequired, IRCUser.Class class_, bool whoisExpired)

Judges whether an event may be triggered, based on the event itself and the annotated Permissions of the handler in question. Implementation function.

prefixPolicyMatches
auto prefixPolicyMatches(IRCEvent event, PrefixPolicy policy, IRCPluginState state)

Evaluates whether or not the message in an event satisfies the PrefixPolicy specified, as fetched from a IRCEventHandler.Command or IRCEventHandler.Regex UDA.

replay
auto replay(Plugin plugin, IRCEvent event, Fun fun, Permissions permissionsRequired, bool inFiber, string caller)

Convenience function that returns a kameloso.plugins.common.Replay of the right type, *with* a subclass plugin reference attached.

sanitiseEvent
void sanitiseEvent(IRCEvent event)

Sanitise event, used upon UTF/Unicode exceptions.

udaSanityCheckCTFE
void udaSanityCheckCTFE(IRCEventHandler uda)

Sanity-checks a plugin's IRCEventHandlers at compile time.

Interfaces

DeferredAction
interface DeferredAction

Embodies the notion of an action a plugin defers to the main thread.

Mixin templates

IRCPluginImpl
mixintemplate IRCPluginImpl(Flag!"debug_" debug_ = No.debug_, string module_ = __MODULE__)

Mixin that fully implements an IRCPlugin.

Structs

Configuration
struct Configuration

Annotation denoting that a variable is the basename of a configuration file or directory.

IRCEventHandler
struct IRCEventHandler

Aggregate to annotate event handler functions with, to control what they do and how they work.

IRCPluginState
struct IRCPluginState

An aggregate of all variables that make up the common state of plugins.

Replay
struct Replay

Embodies the notion of an event to be replayed, once we know more about a user (meaning after a WHOIS query response).

Resource
struct Resource

Annotation denoting that a variable is the basename of a resource file or directory.

Selftester
struct Selftester

Helper struct to aid in testing plugins.

Examples

import kameloso.plugins;
import kameloso.plugins.common;
import kameloso.plugins.common.awareness;

@(IRCEventHandler()
    .onEvent(IRCEvent.Type.CHAN)
    .permissionsRequired(Permissions.anyone)
    .channelPolicy(ChannelPolicy.home)
    .addCommand(
        IRCEventHandler.Command()
            .word("foo")
            .policy(PrefixPolicy.prefixed)
    )
)
void onFoo(FooPlugin plugin, const ref IRCEvent event)
{
    // ...
}

mixin UserAwareness;
mixin ChannelAwareness;
mixin PluginRegistration!FooPlugin;

final class FooPlugin : IRCPlugin
{
    // ...

    mixin IRCPluginImpl;
}

See Also

Meta