Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Setting channel name(s) in HTTPD.pm #1

Open
wants to merge 1 commit into from

1 participant

@dsog

The HTTPD.pm module needs to know the channel name(s) to send the messages to.
However, there were two bugs:

1) It tries to read the channel name from the request contents, which is invalid
since it doesn't exist in the request coming from GitHub.

2) It only reads ONE channel name, but the bot should be able to send the
message to multiple channels.

@dsog dsog Fixes bug(s) reading the channel name.
The HTTP.pm module needs to know the channel name(s) to send the messages to.
However, there were two bugs:

1) It tries to read the channel name from the request contents, which is invalid
since it doesn't exist in the request coming from GitHub.

2) It only reads ONE channel name, but the bot should be able to send the
message to multiple channels.
c82addc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 17, 2011
  1. @dsog

    Fixes bug(s) reading the channel name.

    dsog authored
    The HTTP.pm module needs to know the channel name(s) to send the messages to.
    However, there were two bugs:
    
    1) It tries to read the channel name from the request contents, which is invalid
    since it doesn't exist in the request coming from GitHub.
    
    2) It only reads ONE channel name, but the bot should be able to send the
    message to multiple channels.
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 4 deletions.
  1. +3 −1 lib/Github/IRCBot.pm
  2. +12 −3 lib/Github/IRCBot/HTTPD.pm
View
4 lib/Github/IRCBot.pm
@@ -29,7 +29,9 @@ has httpd => (
lazy => 1,
default => sub {
my $self = shift;
- Github::IRCBot::HTTPD->new( $self->config->{httpd} );
+ my $settings = $self->config->{httpd};
+ $settings->{irc} = $self->irc;
+ Github::IRCBot::HTTPD->new($settings);
},
);
View
15 lib/Github/IRCBot/HTTPD.pm
@@ -11,6 +11,11 @@ has port => (
default => sub { 3000 },
);
+has irc => (
+ is => 'rw',
+ isa => 'Github::IRCBot::IRC'
+);
+
has session => (
is => 'rw',
isa => 'POE::Session',
@@ -40,6 +45,7 @@ has json => (
handles => [qw/decode/],
);
+
sub spawn {
my $self = shift;
$self->session;
@@ -56,12 +62,15 @@ sub poe__start {
'/' => sub {
my ($req, $res) = @_;
my $p = CGI::Simple->new( $req->content );
- my $channel = '#' . $p->param('name');
my $info = $self->decode( $p->param('payload') );
+ my $channels = $self->irc->channels;
for my $commit (@{ $info->{commits} || [] }) {
- $kernel->post( irc => say => $channel =>
- "commit: (03$commit->{author}{name}) $commit->{message} - 14$commit->{url}" );
+ for(@$channels){
+ $kernel->post( irc => say => $_ =>
+ "commit: (03$commit->{author}{name}) ".
+ "$commit->{message} - 14$commit->{url}" );
+ }
}
},
},
Something went wrong with that request. Please try again.