kameloso.plugins

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

admin
module kameloso.plugins.admin

The Admin plugin features bot commands which help with debugging the current state, like printing the current list of users, the current channels, the raw incoming strings from the server, and some other things along the same line.

automode
module kameloso.plugins.automode

The Automode plugin handles automatically setting the modes of users in a channel. The common use-case is to have someone be automatically set to +o (operator) when joining.

bash
module kameloso.plugins.bash

The Bash plugin looks up quotes from bash.org (or technically bashforever.com) and reports them to the appropriate nickname or channel.

chatbot
module kameloso.plugins.chatbot

The Chatbot plugin is a diminishing collection of small, harmless features; like say/echo for simple repeating of text.

common
module kameloso.plugins.common

This module contains common functions and types used by all plugins.

counter
module kameloso.plugins.counter

A simple counter plugin.

help
module kameloso.plugins.help

The Help plugin serves the help command, and nothing else at this point.

note
module kameloso.plugins.note

The Note plugin allows for storing notes to offline users, to be replayed when they next join the channel.

oneliner
module kameloso.plugins.oneliner

The Oneliner plugin serves to provide custom commands, like !vods, !youtube, and any other static-reply !command (provided a prefix of "!").

pipeline
module kameloso.plugins.pipeline

The Pipeline plugin opens a Posix named pipe in a temporary directory or the current directory, to which you can pipe text and have it be sent verbatim to the server. There is also syntax to manually send bus messages to plugins.

poll
module kameloso.plugins.poll

The Poll plugin offers the ability to hold votes/polls in a channel. Any number of choices is supported, as long as they're more than one.

printer
module kameloso.plugins.printer

The Printer plugin takes incoming IRCEvents, formats them into something easily readable and prints them to the screen, optionally with colours. It also supports logging to disk.

quote
module kameloso.plugins.quote

The Quote plugin allows for saving and replaying user quotes.

same
module kameloso.plugins.same

This is an example toy plugin to showcase how one could be written to react to non-!command messages.

sedreplace
module kameloso.plugins.sedreplace

The SedReplace plugin imitates the UNIX sed tool, allowing for the replacement/substitution of text. It does not require the tool itself though, and will work on Windows too.

seen
module kameloso.plugins.seen

The Seen plugin implements "seen"; the ability for someone to query when a given nickname was last encountered online.

services
module kameloso.plugins.services

"Service"-level plugins, used to carry out tasks behind the scenes.

stopwatch
module kameloso.plugins.stopwatch

A simple stopwatch plugin. It offers the ability to start and stop timers, to get how much time passed between the creation of a stopwatch and the cessation of it.

tests
module kameloso.plugins.tests
time
module kameloso.plugins.time

A simple plugin for querying the time in different timezones.

timer
module kameloso.plugins.timer

Plugin offering announcement timers; routines that periodically send lines of text to a channel.

twitch
module kameloso.plugins.twitch

This is a Twitch channel bot. It supports song requests, counting how many times an emote has been used, reporting how long a viewer has been a follower, how much time they have spent watching the stream, and some miscellanea.

unittest_
module kameloso.plugins.unittest_

Unit test plugin.

webtitle
module kameloso.plugins.webtitle

The Webtitle plugin catches URLs pasted in a channel, follows them and reports back the title of the web page that was linked to.

Members

Aliases

priority
alias priority = Priority

Helper alias to use the proper style guide and still be able to instantiate Priority instances with UFCS.

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.

applyCustomSettings
auto applyCustomSettings(IRCPlugin[] plugins, CoreSettings coreSettings, string[] customSettings, bool toPluginsOnly)

Changes a setting of a plugin, given both the names of the plugin and the setting, in string form.

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.

instantiatePlugins
auto instantiatePlugins(IRCPluginState state)

Instantiates all plugins represented by a PluginRegistrationEntry in registeredPlugins.

memoryCorruptionCheck
auto memoryCorruptionCheck(string eventParamName, size_t udaIndex, bool constraints)

Mixin that adds a check to ensure that the event type of the event being handled is one of the expected types for the function it is mixed into.

memoryCorruptionCheckImpl
void memoryCorruptionCheckImpl(IRCEvent event, IRCEventHandler uda, string functionName)

Implementation of the memory corruption check.

memoryCorruptionCheckTestCustomName
void memoryCorruptionCheckTestCustomName(IRCEvent blarp)

Test function for memoryCorruptionCheck with a custom event parameter name.

memoryCorruptionCheckTestCustomNameCustomIndex
void memoryCorruptionCheckTestCustomNameCustomIndex(IRCEvent hirr)

Test function for memoryCorruptionCheck with a custom UDA index.

memoryCorruptionCheckTestDefaultName
void memoryCorruptionCheckTestDefaultName(IRCEvent event)

Test function for memoryCorruptionCheck with default parameters.

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.

registerPlugin
void registerPlugin(Priority priority, IRCPlugin function(IRCPluginState) ctor)

Registers a plugin to be instantiated on program startup/connect by creating a PluginRegistrationEntry and appending it to registeredPlugins.

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

Convenience function that returns a kameloso.plugins.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 event loop for later execution.

Manifest constants

memoryCorruptionCheckConstraintsDefault
enum memoryCorruptionCheckConstraintsDefault;

Changes a setting of a plugin, given both the names of the plugin and the setting, in string form.

Mixin templates

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

Mixin that fully implements an IRCPlugin.

PluginRegistration
mixintemplate PluginRegistration(Plugin, Priority priority = 0.priority, string module_ = __MODULE__)

Mixes in a module constructor that registers the supplied IRCPlugin subclass to be instantiated on program startup/connect.

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.

PluginRegistrationEntry
struct PluginRegistrationEntry

An entry in registeredPlugins corresponding to a plugin registered to be instantiated on program startup/connect.

Priority
struct Priority

Embodies the notion of a priority at which a plugin should be instantiated, and as such, the order in which they will be called to handle events.

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.

Variables

registeredPlugins
PluginRegistrationEntry[] registeredPlugins;

Array of registered plugins, represented by PluginRegistrationEntry/-ies, to be instantiated on program startup/connect.

Examples

import kameloso.plugins;
import kameloso.plugins.common.mixins.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 IRCEvent event)
{
    // ...
}

mixin UserAwareness;
mixin ChannelAwareness;
mixin PluginRegistration!FooPlugin;

final class FooPlugin : IRCPlugin
{
    // ...

    mixin IRCPluginImpl;
}

See Also

Meta