3 our $VERSION = '0.0.1';
5 use POE qw(Component::Server::IRC);
7 with qw(MooseX::Getopt);
8 with qw(MooseX::Daemonize);
13 default => sub { 'moose.room' },
19 default => sub { 15 },
25 default => sub { 'MooseRoom' },
29 isa => 'POE::Component::Server::IRC',
33 POE::Component::Server::IRC->spawn(
35 servername => $_[0]->servername,
36 nicklen => $_[0]->nicklen,
48 [ { username => 'perigrin', password => 'hobbit' }, ];
54 POE::Session->create( object_states => [ $self => [qw(_start _default)], ],
60 my ( $self, $kernel, $heap ) = @_[ OBJECT, KERNEL, HEAP ];
61 $self->ircd->yield('register');
63 # Anyone connecting from the loopback gets spoofed hostname
64 $self->ircd->add_auth(
65 mask => '*@localhost',
66 spoof => $self->hostname,
70 # We have to add an auth as we have specified one above.
71 $self->ircd->add_auth( mask => '*@*' );
73 # Start a listener on the 'standard' IRC port.
74 $self->ircd->add_listener( port => 6667 );
76 # Add an operator who can connect from localhost
77 $self->ircd->add_operator($_) for $self->operators;
82 my ( $event, $args ) = @_[ ARG0 .. $#_ ];
83 print STDOUT "$event: ";
86 if ( ref($_) eq 'ARRAY' ) {
87 print STDOUT "[", join( ", ", @$_ ), "] ";
90 if ( ref($_) eq 'HASH' ) {
91 print STDOUT "{", join( ", ", %$_ ), "} ";
98 return 0; # Don't handle signals.
101 before new => sub { POE::Kernel->run(); };
102 after start => sub { POE::Kernel->run(); };
104 unless ( caller() ) {
106 my $cmd = lc $ARGV[-1];
107 my $app = MooseRoom->new_with_options( pidbase => Cwd::cwd() );
108 print STDERR "trying to $cmd server\n";
109 if ( $cmd eq 'start' ) {
111 pidfile: @{ [ $app->pidfile ] }
112 port: @{ [ $app->Port ] }
119 1; # Magic true value required at end of module