Changeset 14284 for lang/perl/App-Nakanobu
- Timestamp:
- 06/20/08 12:38:50 (5 months ago)
- Location:
- lang/perl/App-Nakanobu/trunk
- Files:
-
- 3 modified
-
lib/App/Nakanobu/Plugin/Component/IRCClient.pm (modified) (2 diffs)
-
lib/App/Nakanobu/Plugin/Component/JSONRPC/HTTP.pm (modified) (2 diffs)
-
tools/jsonrpc-client.pl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/App-Nakanobu/trunk/lib/App/Nakanobu/Plugin/Component/IRCClient.pm
r14220 r14284 82 82 ); 83 83 84 # hook some channels. 84 85 for my $command (qw(notice privmsg)) { 85 86 $context->register_hook( … … 92 93 ); 93 94 } 95 96 $context->register_hook( 97 'channels' => $self => sub { 98 my ($self, ) = @_; 99 $self->channels; 100 }, 101 ); 94 102 }; 95 103 -
lang/perl/App-Nakanobu/trunk/lib/App/Nakanobu/Plugin/Component/JSONRPC/HTTP.pm
r14207 r14284 25 25 26 26 my $method_map = { 27 map {27 map({ 28 28 $_ => sub { 29 29 my $command = $_; … … 34 34 } 35 35 }->() 36 } qw(notice privmsg) 36 } qw(notice privmsg)), 37 channels => sub { 38 [ 39 map { @{ $_ } } # flatten 40 @{ App::Nakanobu->context->run_hook( 'channels' ) } 41 ] 42 }, 37 43 }; 38 44 -
lang/perl/App-Nakanobu/trunk/tools/jsonrpc-client.pl
r14250 r14284 4 4 use JSON::RPC::Client; 5 5 6 my $uri = 'http://localhost:5555/';7 my $method = 'privmsg';8 my $params = {channel => '#てすと', text => "abcあいうえお123\n456" };9 6 10 my $client = JSON::RPC::Client->new; 11 my $res = $client->call($uri, { method => $method, params => $params } ); 12 if ($res) { 13 if ($res->is_error) { 14 warn $res->error_message; 7 call( 'http://localhost:5555/', 'privmsg', 8 { channel => '#てすと', text => "abcあいうえお123\n456" }, 9 ); 10 11 call( 'http://localhost:5555/', 'channels', {}); 12 13 sub call { 14 my ($uri, $method, $params) = @_; 15 16 my $client = JSON::RPC::Client->new; 17 my $res = $client->call($uri, { method => $method, params => $params } ); 18 if ($res) { 19 if ($res->is_error) { 20 warn $res->error_message; 21 } else { 22 use Data::Dumper; warn Dumper($res->result); 23 print $res->result, "\n"; 24 } 15 25 } else { 16 use Data::Dumper; warn Dumper($res->result); 17 print $res->result, "\n"; 26 print $client->status_line; 18 27 } 19 } else {20 print $client->status_line;21 28 } 22
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)