Changeset 11745 for lang/perl/XIRCD
- Timestamp:
- 05/17/08 16:52:21 (5 years ago)
- Location:
- lang/perl/XIRCD/trunk/lib
- Files:
-
- 1 added
- 3 modified
-
XIRCD.pm (modified) (1 diff)
-
XIRCD/Component.pm (modified) (2 diffs)
-
XIRCD/Component/Time.pm (modified) (1 diff)
-
XIRCD/Role.pm (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/XIRCD/trunk/lib/XIRCD.pm
r11669 r11745 19 19 20 20 for my $component ( @{$config->{components}} ) { 21 my $module = $component->{module};21 my $module = 'XIRCD::Component::' . $component->{module}; 22 22 $module->require; 23 $module->new( config => $component ); 23 $module->new( 24 name => lc($component->{module}), 25 channel => '#' . lc($component->{module}), 26 %{$component} 27 ); 28 warn "load $module"; 24 29 } 25 30 -
lang/perl/XIRCD/trunk/lib/XIRCD/Component.pm
r11679 r11745 6 6 7 7 use Sub::Exporter -setup => { 8 exports => [qw(self debug get_args http_alias )],8 exports => [qw(self debug get_args http_alias yield delay post publish_message publish_notice)], 9 9 groups => { 10 10 default => [ -all ], … … 24 24 } 25 25 26 sub yield (@) { ## no critic. 27 POE::Kernel->yield(@_); 28 } 29 30 sub delay (@) { ## no critic. 31 POE::Kernel->delay(@_); 32 } 33 34 sub post (@) { ## no critic. 35 POE::Kernel->post(@_); 36 } 37 38 sub publish_message ($$) { ## no critic. 39 my $self = (caller_args(1))[0]; 40 my ($nick, $text) = @_; 41 42 post ircd => 'publish_message' => $nick, $self->channel, $text; 43 } 44 45 sub publish_notice ($) { ## no critic. 46 my $self = (caller_args(1))[0]; 47 my ($text,) = @_; 48 49 post ircd => 'publish_notice' => $self->channel, $text; 50 } 51 26 52 27 53 1; -
lang/perl/XIRCD/trunk/lib/XIRCD/Component/Time.pm
r11679 r11745 3 3 use XIRCD::Component; 4 4 5 with qw(MooseX::POE::Aliased); 5 with qw(XIRCD::Role); 6 7 has 'nick' => ( isa => 'Str', io => 'rw' ); 6 8 7 9 use DateTime; 8 10 9 has 'config' => ( 10 isa => 'HashRef', 11 is => 'rw', 12 ); 13 14 has 'date' => ( 15 isa => 'DateTime', 16 is => 'ro', 17 default => sub { DateTime->now( time_zone => 'Asia/Tokyo' ) }, 18 ); 19 20 sub START { 21 self->alias('time'); 22 23 debug 'start time'; 24 25 POE::Kernel->post( ircd => 'join_channel', self->config->{channel} ); 26 self->yield('timecall'); 27 } 28 29 event timecall => sub { 30 debug "timecall"; 31 32 POE::Kernel->post( 33 ircd => 'publish_message' => 'time', 34 self->config->{channel}, self->date->strftime("%Y/%m/%d %H:%M:%S") 35 ); 36 POE::Kernel->delay( 'timecall', 10 ); 11 event start => sub { 12 my $date = DateTime->now(time_zone => 'Asia/Tokyo'); 13 publish_message self->nick => $date->strftime("%Y/%m/%d %H:%M:%S"); 14 delay 'start', 10; 37 15 }; 38 16
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)