Dirk



class  IrcErrorException: object.Exception;

Thrown if the server sends an error message to the client.


class  IrcClient;

Represents an IRC client connection.

Use the separate type irc.tracker.IrcTracker returned by irc.tracker.track to keep track of the channels the user for this connection is a member of, and the members of those channels.


this();
this(Socket socket);

Create a new unconnected IRC client.

If socket is provided, it must be an unconnected TCP socket. Provide an instance of ssl.socket.SslSocket to use SSL/TLS.

User information should be configured before connecting. Only the nick name can be changed after connecting. Event callbacks can be added both before and after connecting.

See Also
IrcClient.connect

void  connect(Address serverAddress, in char[] password);
void  connect(Address serverAddress);

Connect this client to a server.

Parameters
Address serverAddress address of server
char[] password server password, or null to specify no password

bool  read();

Read all available data from the connection, parse all complete IRC messages and invoke registered callbacks.

Returns
true if the connection was closed.
See Also
irc.eventloop.IrcEventLoop.run

void  writef(T...)(in char[] messageFormat, T formatArgs) if (T.length);
void  writef(in char[] rawline);

Write a raw IRC protocol message to the connection stream.

If there is more than one argument, then the first argument is formatted with subsequent arguments. Arguments must not contain newlines. Messages longer than 510 characters (UTF-8 code units) will be cut off. It is the caller's responsibility to ensure a cut-off message is valid.

See Also
std.format.formattedWrite
Throws
irc.exception.UnconnectedClientException if this client is not connected.

void  send(in char[] target, in char[] message);
void  send(Range)(in char[] target, Range message) if (isInputRange!Range && isSomeChar!(ElementType!Range));

Send lines of chat to a channel or user. Each line in message is sent as one message. Lines exceeding the IRC message length limit will be split up into multiple messages.

Parameters
char[] target channel or nick name to send to
char[] message message(s) to send. Can contain multiple lines.
Throws
irc.exception.UnconnectedClientException if this client is not connected.

void  sendf(FormatArgs...)(in char[] target, in char[] fmt, FormatArgs fmtArgs);

Send formatted lines of chat to a channel or user. Each line in the formatted result is sent as one message. Lines exceeding the IRC message length limit will be split up into multiple messages.

Parameters
char[] target channel or nick name to send to
char[] fmt message format
FormatArgs fmtArgs format arguments
Throws
irc.exception.UnconnectedClientException if this client is not connected.
See Also
std.format.formattedWrite

void  notice(in char[] target, in char[] message);
void  notice(Range)(in char[] target, Range message) if (isInputRange!Range && isSomeChar!(ElementType!Range));

Send notices to a channel or user. Each line in message is sent as one notice. Lines exceeding the IRC message length limit will be split up into multiple notices.

Parameters
char[] target channel or nick name to notice
char[] message notices(s) to send. Can contain multiple lines.
Throws
irc.exception.UnconnectedClientException if this client is not connected.

void  noticef(FormatArgs...)(in char[] target, in char[] fmt, FormatArgs fmtArgs);

Send formatted notices to a channel or user. Each line in the formatted result is sent as one notice. Lines exceeding the IRC message length limit will be split up into multiple notices.

Parameters
char[] target channel or nick name to send to
char[] fmt message format
FormatArgs fmtArgs format arguments
Throws
irc.exception.UnconnectedClientException if this client is not connected.
See Also
std.format.formattedWrite

void  ctcpQuery(in char[] target, in char[] query);
void  ctcpQuery(in char[] target, in char[] tag, in char[] data);

Send a CTCP query to a channel or user.


void  ctcpReply(in char[] targetNick, in char[] reply);
void  ctcpReply(in char[] targetNick, in char[] tag, in char[] data);

Send a CTCP reply to a user.


void  ctcpError(in char[] targetNick, in char[] invalidData, in char[] error);

Send a CTCP error message reply.

Parameters
char[] invalidData data that caused the error
char[] error human-readable error message

const @property bool  connected();

Check if this client is connected.


inout pure @property inout(Address)  serverAddress();

Address of the server this client is currently connected to, or null if this client is not connected.


const pure @property string  realName();
@property void  realName(string newRealName);

Real name of the user for this client.

Cannot be changed after connecting.


const pure @property string  userName();
@property void  userName(string newUserName);

User name of the user for this client.

Cannot be changed after connecting.


const pure @property string  nickName();
@property void  nickName(in char[] newNick);
@property void  nickName(string newNick);
deprecated alias  nick = nickName;

Nick name of the user for this client.

Setting this property when connected can cause the IrcClient.onNickInUse event to fire.


const pure nothrow @nogc @property string  networkName();

The name of the IRC network the server is part of, or null if the server has not advertised the network name.


const pure nothrow @nogc @property ushort  maxNickNameLength();

The maximum number of characters (bytes) allowed in this user's nick name.

The limit is network-specific.


void  addUserModes(in char[] modes...);
void  removeUserModes(in char[] modes...);

Add or remove user modes to/from this user.


void  addToChannelList(in char[] channel, char list, in char[][] addresses...);
void  removeFromChannelList(in char[] channel, char list, in char[][] addresses...);

Add or remove an address to/from a channel list.

Examples
Ban Alice and Bob from channel #foo:
client.addToChannelList("#foo", 'b', "Alice!*@*", "Bob!*@*");

struct  ChannelMode;
void  addChannelModes(in char[] channel, ChannelMode[] modes...);
void  removeChannelModes(in char[] channel, ChannelMode[] modes...);

Add or remove channel modes in the given channel.

Examples
Give channel operator status (+o) to Alice and voice status (+v) to Bob in channel #foo:
client.addChannelModes("#foo", ChannelMode('o', "Alice"), ChannelMode('v', "Bob"));

char  mode;
const(char)[]  argument;




void  join(in char[] channel);

Join a channel.

Parameters
char[] channel channel to join
Throws
irc.exception.UnconnectedClientException if this client is not connected.

void  join(in char[] channel, in char[] key);

Join a passworded channel.

Parameters
char[] channel channel to join
char[] key channel password
Throws
irc.exception.UnconnectedClientException if this client is not connected.

void  part(in char[] channel);

Leave a channel.

Parameters
char[] channel channel to leave
Throws
irc.exception.UnconnectedClientException if this client is not connected.

void  part(in char[] channel, in char[] message);

Leave a channel with a parting message.

Parameters
char[] channel channel to leave
char[] message parting message
Throws
irc.exception.UnconnectedClientException if this client is not connected.

void  kick()(in char[] channel, in char[] user);
void  kick()(in char[] channel, in char[] user, in char[] comment);
void  kick(Range)(in char[] channel, Range users) if (isInputRange!Range && isSomeString!(ElementType!Range));
void  kick(Range)(in char[] channel, Range users, in char[] comment) if (isInputRange!Range && isSomeString!(ElementType!Range));

Kick one or more users from a channel.

This user must have channel operator status in channel.

Parameters
char[] channel channel to  kick user(s) from
Range users user(s) to  kick
char[] comment comment to broadcast with the kick message, which typically contains the reason the user is being kicked

void  kick(Range)(Range channelUserPairs) if (isInputRange!Range && isTuple!(ElementType!Range) && ElementType!Range.length == 2 && allSatisfy!(isSomeString, ElementType!Range.Types));
void  kick(Range)(Range channelUserPairs, in char[] comment) if (isInputRange!Range && isTuple!(ElementType!Range) && ElementType!Range.length == 2 && allSatisfy!(isSomeString, ElementType!Range.Types));

Kick users from channels in a single message.

channelUserPairs must be a range of std.typecons.Tuple pairs of strings, where the first string is the name of a channel and the second string is the user to  kick from that channel.


void  queryUserhost(in char[][] nicks...);

Query the user name and host name of up to 5 users.

Parameters
char[][] nicks between 1 and 5 nick names to query
See Also
IrcClient.onUserhostReply

void  queryWhois(in char[] nick);

Query information about a particular user.

Parameters
char[] nick target user's nick name
See Also
IrcClient.onWhoisReply

void  queryNames(in char[][] channels...);

Query the list of members in the given channels.

See Also
IrcClient.onNameList

void  quit(in char[] message);

Leave and disconnect from the server.

Parameters
char[] message comment sent in quit notification
Throws
irc.exception.UnconnectedClientException if this client is not connected.

void delegate()[]  onConnect;

Invoked when this client has successfully connected to a server.


void delegate(IrcUser user, in char[] target, in char[] message)[]  onMessage;

Invoked when a message is picked up by the user for this client.

Parameters
user user who sent the message
target message target. This is either the nick of this client in the case of a personal message, or the name of the channel which the message was sent to.

void delegate(IrcUser user, in char[] target, in char[] message)[]  onNotice;

Invoked when a notice is picked up by the user for this client.

Parameters
user user who sent the notice
target notice target. This is either the nick of this client in the case of a personal notice, or the name of the channel which the notice was sent to.

void delegate(IrcUser user, in char[] newNick)[]  onNickChange;

Invoked when a user receives a new nickname.

When the user is this user, the IrcClient.nick property will return the old nickname until after all onNickChange callbacks have been invoked.

Parameters
user user which nickname was changed; the nick field contains the old nickname. Can be this user
newNick new nickname of user

void delegate(in char[] channel)[]  onSuccessfulJoin;

Invoked following a call to IrcClient.join when the channel was successfully joined.

Parameters
channel channel that was successfully joined

void delegate(IrcUser user, in char[] channel)[]  onJoin;

Invoked when another user joins a channel that this user is a member of.

Parameters
user joining user
channel channel that was joined

void delegate(IrcUser user, in char[] channel)[]  onPart;

Invoked when a user parts a channel that this user is a member of. Also invoked when this user parts a channel.

Parameters
user parting user
channel channel that was parted

void delegate(IrcUser user, in char[] comment)[]  onQuit;

Invoked when another user disconnects from the network.

Parameters
user disconnecting user
comment quit message

void delegate(IrcUser kicker, in char[] channel, in char[] kickedNick, in char[] comment)[]  onKick;

Invoked when a user is kicked (forcefully removed) from a channel that this user is a member of.

Parameters
kicker user that initiated the kick
channel channel from which the user was kicked
kickedNick nickname of the user that was kicked
comment comment sent with the kick; usually describing the reason the user was kicked. Can be null

void delegate(in char[] channel, in char[][] nickNames)[]  onNameList;

Invoked when a list of member nick names for a channel are received.

The list is received after a successful join to a channel by this user, or when explicitly queried with IrcClient.queryNames.

The list for a single invocation is partial; the event can be invoked several times for the same channel as a response to a single trigger. The list is signaled complete when IrcClient.onNameListEnd is invoked.

Parameters
channel channel of which the users are members
nickNames list of member nicknames

void delegate(in char[] channel)[]  onNameListEnd;

Invoked when the complete list of members of a channel have been received. All invocations of onNameList between invocations of this event are part of the same member list.

See Also
IrcClient.onNameList

void delegate(IrcUser user, in char[] source, in char[] tag, in char[] data)[]  onCtcpQuery;

Invoked when a CTCP query is received in a message. IrcClient.onMessage is not invoked for the given message when  onCtcpQuery has a non-zero number of registered handlers.

Note:
This callback is only invoked when there is a CTCP message at the start of the message, and any subsequent CTCP messages in the same message are discarded. To handle multiple CTCP queries in one message, use IrcClient.onMessage with irc.ctcp.ctcpExtract.

void delegate(IrcUser user, in char[] source, in char[] tag, in char[] data)[]  onCtcpReply;

Invoked when a CTCP reply is received in a notice. IrcClient.onNotice is not invoked for the given notice when  onCtcpReply has a non-zero number of registered handlers.

Note:
This callback is only invoked when there is a CTCP message at the start of the notice, and any subsequent CTCP messages in the same notice are discarded. To handle multiple CTCP replies in one notice, use IrcClient.onNotice with irc.ctcp.ctcpExtract.

const(char)[] delegate(in char[] newNick)[]  onNickInUse;

Invoked when the requested nick name of the user for this client is already in use.

Return a non-null string to provide a new nick. No further callbacks in the list are called once a callback provides a nick.

Parameters
newNick the nick name that was requested.
Note:
The current nick name can be read from the IrcClient.nick property of this client.

void delegate(in char[] channel, in char[] topic)[]  onTopic;

Invoked when a channel is joined, a topic is set in a channel or when the current topic was requested.

Parameters
topic topic or new topic for channel

void delegate(in char[] channel, in char[] nick, in char[] time)[]  onTopicInfo;

Invoked when a channel is joined or when the current topic was requested.

Parameters
nick nick name of user who set the topic
time time the topic was set

void delegate(in IrcUser[] users)[]  onUserhostReply;

Invoked with the reply of a userhost query.

See Also
IrcClient.queryUserhost

void delegate(IrcUser userInfo, in char[] realName)[]  onWhoisReply;
void delegate(in char[] nick, in char[] serverHostName, in char[] serverInfo)[]  onWhoisServerReply;
void delegate(in char[] nick)[]  onWhoisOperatorReply;
void delegate(in char[] nick, int idleTime)[]  onWhoisIdleReply;
void delegate(in char[] nick, in char[][] channels)[]  onWhoisChannelsReply;
void delegate(in char[] nick, in char[] accountName)[]  onWhoisAccountReply;
void delegate(in char[] nick)[]  onWhoisEnd;

Invoked when a WHOIS reply is received.

See Also
IrcClient.queryWhois