IRC::Indexer::Report::Server - Server information class for IRC::Indexer
## Create new blank server info obj: my $info = IRC::Indexer::Report::Server->new; . . . add trawler data via methods . . . ## Get server's info as hash: my $ref = $info->netinfo; ## Construct from previously-exported hash: my $info = IRC::Indexer::Report::Server->new( FromHash => $previous->netinfo(), ); ## See below for other methods.
Represents the results of a single trawled server.
This is the object returned by "info" in IRC::Indexer::Trawl::Bot -- it can be used to pull out specific pieces of information about a trawl run (or a complete dump), or fed to an IRC::Indexer::Report::Network to be merged into a network summary.
Returns the entire NetInfo hash, as documented below ("netinfo hash").
Returns a cloned copy of the current state of the NetInfo hash, as opposed to the reference returned by "netinfo".
If NoChannels is specified, HashChans and ListChans will be excluded from the cloned dump:
my $without_chans = $info->clone(NoChannels => 1);
Get or set the current status.
Valid values are:
undef -- not started INIT -- started CONNECTED -- connected to IRC FAIL -- error encountered DONE -- finished
Get or set the current error string.
Should be boolean false if there have been no fatal errors.
Get or set the start timestamp (epoch seconds)
Get or set the time the trawler connected to IRC.
Get or set the time the trawler finished this run.
Get or set the network name; this is the name announced via ISUPPORT (NETWORK=). If the queried network doesn't announce NETWORK=, the server name will be supplied.
Get or set the target server; this is the address the bot is trawling, not necessarily the announced server name (see "server")
Get or set the actual server name; this is the name announced by the server, not necessarily the address we originally connected to.
Get or set the server version.
Clear the existing MOTD.
With no arguments, gets the current MOTD (or undef). This will be an array reference containing MOTD lines.
If an argument is specified, it is pushed to the end of the current MOTD array.
Get or set the current global user count, as reported by LUSERS.
Get or set the current global oper count, as reported by LUSERS.
With no arguments, returns an array reference containing LINKS output (or undef).
If an argument is specified, it should be an array reference containing raw LINKS lines.
Get the total number of channels found in LIST.
This is calculated from "chanhash" and cannot be set directly; use "add_channel" to add a channel.
Returns an array of arrays, sorted by user count (highest first), of channel names and their respective user counts and topics:
my $listchans = $info->channels; for my $item (@$listchans) { my ($name, $count, $topic) = @$item; . . . }
Returns a hash, keyed on channel name, of the results of LIST.
Keys are Users and Topic:
my $chans = $info->chanhash; for my $channel (keys %$chans) { my $this_chan = $chans->{$channel}; my $user_count = $this_chan->{Users}; my $last_topic = $this_chan->{Topic}; . . . }
Used by trawlers to append a channel from LIST output.
Adds a channel to the channel hash (see "chanhash"):
## in a LIST handler: $info->add_channel($chan, $users, $topic);
The netinfo method returns a hash with the following keys:
Status Failure ConnectedTo ServerName NetName GlobalUsers OperCount ListLinks ListChans MOTD IRCD StartedAt ConnectedAt FinishedAt
These all roughly correspond to their respective accessors, documented above.
See IRC::Indexer::POD::ServerSpec for details.
Jon Portnoy <avenj@cobaltirc.org>
To install IRC::Indexer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IRC::Indexer
CPAN shell
perl -MCPAN -e shell install IRC::Indexer
For more information on module installation, please visit the detailed CPAN module installation guide.