privmsg

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

This reflects how channel messages and private messages are both the underlying same type; PRIVMSG.

void
privmsg
(,
const string channel
,
const string nickname
,
const string content
,,
const string caller = __FUNCTION__
)

Parameters

state IRCPluginState

The current plugin's IRCPluginState, via which to send messages to the server.

channel string

Channel in which to send the message, if applicable.

nickname string

Nickname of user to which to send the message, if applicable.

content string

Message body content to send.

properties Message.Property

Custom message properties, such as Message.Property.quiet and Message.Property.forced.

caller string

String name of the calling function, or something else that gives context.

Examples

IRCPluginState state;

{
    privmsg(state, "#channel", string.init, "content");

    immutable m = state.outgoingMessages.data[0];
    with (m.event)
    {
        assert((type == IRCEvent.Type.CHAN), Enum!(IRCEvent.Type).toString(type));
        assert((channel == "#channel"), channel);
        assert((content == "content"), content);
        assert(!target.nickname.length, target.nickname);
        assert(m.properties == Message.Property.init);
    }

    state.outgoingMessages.clear();
}
{
    privmsg(state, string.init, "kameloso", "content");

    immutable m = state.outgoingMessages.data[0];
    with (m.event)
    {
        assert((type == IRCEvent.Type.QUERY), Enum!(IRCEvent.Type).toString(type));
        assert(!channel.length, channel);
        assert((target.nickname == "kameloso"), target.nickname);
        assert((content == "content"), content);
        assert(m.properties == Message.Property.init);
    }
}