kameloso.messaging

Functions used to send messages to the server.

To send a server message some information is needed; like message type, message target, perhaps channel, content and such. IRCEvent has all of this, so it lends itself to repurposing it to aggregate and carry them, through message structs in an array "queue". These are caught by the main loop, which reversely parses them into strings and sends them on to the server.

Members

Aliases

askToCritical
alias askToCritical = askToOutputImpl!"askToCritical"

Sends a message to the main thread to KamelosoLogger.critical text to the local terminal.

askToError
alias askToError = askToOutputImpl!"askToError"

Sends a message to the main thread to KamelosoLogger.error text to the local terminal.

askToFatal
alias askToFatal = askToOutputImpl!"askToFatal"

Sends a message to the main thread to KamelosoLogger.fatal text to the local terminal.

askToInfo
alias askToInfo = askToOutputImpl!"askToInfo"

Sends a message to the main thread to KamelosoLogger.info text to the local terminal.

askToLog
alias askToLog = askToOutputImpl!"askToLog"

Sends a message to the main thread to KamelosoLogger.log text to the local terminal.

askToTrace
alias askToTrace = askToOutputImpl!"askToTrace"

Sends a message to the main thread to KamelosoLogger.trace text to the local terminal.

askToWarn
alias askToWarn = askToOutputImpl!"askToWarn"

Sends a message to the main thread to KamelosoLogger.warning text to the local terminal.

askToWarning
alias askToWarning = askToWarn

Simple alias to askToWarn, because both spellings are right.

askToWarning
alias askToWarning = askToWarn

Simple alias to askToWarn, because both spellings are right.

askToWriteln
alias askToWriteln = askToOutputImpl!"askToWriteln"

Sends a message to the main thread asking to print text to the local terminal.

immediateline
alias immediateline = immediate

Merely an alias to immediate, because we use both terms at different places.

Functions

askToOutputImpl
void askToOutputImpl(IRCPluginState state, string line)

Sends a message asking to print the supplied text to the local terminal, instead of doing it directly.

chan
void chan(IRCPluginState state, string channelName, string content, Message.Property properties, string caller)

Sends a channel message.

emote
void emote(IRCPluginState state, string emoteTarget, string content, Message.Property properties, string caller)

Sends an ACTION "emote" to the supplied target (nickname or channel).

immediate
void immediate(IRCPluginState state, string line, Message.Property properties, string caller)

Immediately sends text to the server, verbatim. Skips all queues.

invite
void invite(IRCPluginState state, string channel, string nickname, Message.Property properties, string caller)

Invites a user to a channel.

join
void join(IRCPluginState state, string channel, string key, Message.Property properties, string caller)

Joins a channel.

kick
void kick(IRCPluginState state, string channel, string nickname, string reason, Message.Property properties, string caller)

Kicks a user from a channel.

mode
void mode(IRCPluginState state, string channel, const(char)[] modes, string content, Message.Property properties, string caller)

Sets a channel mode.

part
void part(IRCPluginState state, string channel, string reason, Message.Property properties, string caller)

Leaves a channel.

privmsg
void privmsg(IRCPluginState state, string channel, string nickname, string content, Message.Property properties, string caller)

Sends either a channel message or a private query message depending on the arguments passed to it.

query
void query(IRCPluginState state, string nickname, string content, Message.Property properties, string caller)

Sends a private query message to a user.

quit
void quit(IRCPluginState state, string reason, Message.Property properties, string caller)

Disconnects from the server, optionally with a quit reason.

raw
void raw(IRCPluginState state, string line, Message.Property properties, string caller)

Sends text to the server, verbatim.

reply
void reply(IRCPluginState state, IRCEvent event, string content, Message.Property properties, string caller)

Replies to a message in a Twitch channel. Requires version TwitchSupport, without which it will just pass on to chan.

topic
void topic(IRCPluginState state, string channel, string content, Message.Property properties, string caller)

Sets the topic of a channel.

whois
void whois(IRCPluginState state, string nickname, Message.Property properties, string caller)

Queries the server for WHOIS information about a user.

Structs

Message
struct Message

An IRCEvent with some metadata, to be used when crafting an outgoing message to the server.

Examples

//IRCPluginState state;

chan(state, "#channel", "Hello world!");
query(state, "nickname", "foo bar");
mode(state, "#channel", "nickname", "+o");
topic(state, "#channel", "I thought what I'd do was, I'd pretend I was one of those deaf-mutes.");

Having to supply the IRCPluginState on every call can be avoided for plugins, by mixing in MessagingProxy

and placing the messaging function calls inside a with (plugin) block.

IRCPluginState state;
auto plugin = new MyPlugin(state);  // has mixin MessagingProxy;

with (plugin)
{
    chan("#channel", "Foo bar baz");
    query("nickname", "hello");
    mode("#channel", string.init, "+b", "dudebro!*@*");
    mode(string.init, "nickname", "+i");
}

See Also

Meta