Net-IRC

 view release on metacpan or  search on metacpan

Connection.pm  view on Meta::CPAN

my %_udef = ();

# Creates a new IRC object and assigns some default attributes.
sub new {
  my $proto = shift;
  
  my $self = {                # obvious defaults go here, rest are user-set
    _debug      => $_[0]->{_debug},
    _port       => 6667,
    # Evals are for non-UNIX machines, just to make sure.
    _username   => eval { scalar getpwuid($>) } || $ENV{USER} || $ENV{LOGNAME} || "japh",
    _ircname    => $ENV{IRCNAME} || eval { (getpwuid($>))[6] } || "Just Another Perl Hacker",
    _nick       => $ENV{IRCNICK} || eval { scalar getpwuid($>) } || $ENV{USER} || $ENV{LOGNAME} || "WankerBot",
    _ignore     => {},
    _handler    => {},
    _verbose    =>  0,       # Is this an OK default?
    _parent     =>  shift,
    _frag       =>  '',
    _connected  =>  0,
    _maxlinelen =>  510,     # The RFC says we shouldn't exceed this.
    _lastsl     =>  0,
    _pacing     =>  0,       # no pacing by default
    _ssl	=>  0,       # no ssl by default

Connection.pm  view on Meta::CPAN

  }
  
  # Lots of error-checking claptrap first...
  unless ($self->server) {
    unless ($ENV{IRCSERVER}) {
      croak "No server address specified in connect()";
    }
    $self->server( $ENV{IRCSERVER} );
  }
  unless ($self->nick) {
    $self->nick($ENV{IRCNICK} || eval { scalar getpwuid($>) }
                || $ENV{USER} || $ENV{LOGNAME} || "WankerBot");
  }
  unless ($self->port) {
    $self->port($ENV{IRCPORT} || 6667);
  }
  unless ($self->ircname)  {
    $self->ircname($ENV{IRCNAME} || eval { (getpwuid($>))[6] }
                   || "Just Another Perl Hacker");
  }
  unless ($self->username) {
    $self->username(eval { scalar getpwuid($>) } || $ENV{USER}
                    || $ENV{LOGNAME} || "japh");
  }
  
  # Now for the socket stuff...
  if ($self->connected) {
    $self->quit("Changing servers");
  }
  
  if($self->ssl) {
    require IO::Socket::SSL;



( run in 0.279 second using v1.01-cache-2.11-cpan-8d75d55dd25 )