WHOISFiberDelegate

Functionality for catching WHOIS results and calling passed function aliases with the resulting account information that was divined from it, in the form of the actual IRCEvent, the target IRCUser within it, the user's account field, or merely alone as an arity-0 function.

The mixed in function to call is named enqueueAndWHOIS. It will construct the fiber, enqueue it as awaiting the proper IRCEvent types, and issue the WHOIS query.

mixin template WHOISFiberDelegate (
alias onSuccess
alias onFailure = null
Flag!"alwaysLookup" alwaysLookup = No.alwaysLookup
) {
static if(!isSomeFunction!onSuccess)
enum pattern;
static if(!isSomeFunction!onSuccess)
enum message;
static if(!(!isSomeFunction!onSuccess))
static if(!isSomeFunction!onFailure && !is(typeof(onFailure) == typeof(null)))
enum pattern;
static if(!(!isSomeFunction!onSuccess))
static if(!isSomeFunction!onFailure && !is(typeof(onFailure) == typeof(null)))
enum message;
static if((paramNames.length == 0) || !is(typeof(mixin (paramNames[0])) : IRCPlugin))
enum pattern;
static if((paramNames.length == 0) || !is(typeof(mixin (paramNames[0])) : IRCPlugin))
enum message;
}

Members

Functions

enqueueAndWHOIS
void enqueueAndWHOIS(string nickname, Flag!"issueWhois" issueWhois, Flag!"background" background)

Constructs a CarryingFiber carrying a IRCEvent and enqueues it into the IRCPluginState.awaitingFibers

associative array, then issues a WHOIS query (unless overridden via the issueWhois parameter).

whoisFiberDelegate
void whoisFiberDelegate()

Reusable mixin that catches WHOIS results.

Manifest constants

hasWHOISFiber
enum hasWHOISFiber;

Flag denoting that WHOISFiberDelegate has been mixed in.

Static variables

whoisEventTypes
IRCEvent.Type[6] whoisEventTypes;

Event types that we may encounter as responses to WHOIS queries.

Variables

_carriedNickname
string _carriedNickname;

Nickname being looked up, stored outside of any separate function to make it available to all of them.

Parameters

onSuccess

Function alias to call when successfully having received account information from the server's WHOIS response.

onFailure

Function alias to call when the server didn't respond with account information, or when the user is offline.

alwaysLookup

Whether or not to always issue a WHOIS query, even if the requested user's account is already known.

Examples

void onSuccess(const ref IRCEvent successEvent) { /* ... */ }
void onFailure(const IRCUser failureUser) { /* .. */ }

mixin WHOISFiberDelegate!(onSuccess, onFailure);
enqueueAndWHOIS(specifiedNickname);