summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-02-16 22:55:48 -0600
committerJesse Luehrs <doy@tozt.net>2012-02-16 22:59:19 -0600
commit48345713b87ac389c68c46173994a96560266f52 (patch)
treef29d850f397c83763a3773eabb08ae093bf55410
parentcc3ec78d63fac61603e3fa197c455cc4e825d798 (diff)
downloadbot-flowdock-irc-48345713b87ac389c68c46173994a96560266f52.tar.gz
bot-flowdock-irc-48345713b87ac389c68c46173994a96560266f52.zip
start implementing some inbox events
-rw-r--r--lib/Bot/Flowdock/IRC.pm38
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/Bot/Flowdock/IRC.pm b/lib/Bot/Flowdock/IRC.pm
index 832fe24..0389eff 100644
--- a/lib/Bot/Flowdock/IRC.pm
+++ b/lib/Bot/Flowdock/IRC.pm
@@ -135,7 +135,12 @@ sub tick {
}
}
elsif ($app eq 'influx') { # i think this is timeline stuff
- # ...
+ if ($type eq 'vcs' && any { /^github/ } @{ $event->{tags} }) {
+ $self->flowdock_github_event($event);
+ }
+ else {
+ $self->flowdock_unknown_inbox_event($event);
+ }
}
else {
# we don't care activity events
@@ -182,6 +187,37 @@ sub flowdock_user_edit {
$self->_set_name_for_id($id, $nick);
}
+sub flowdock_github_event {
+ my $self = shift;
+ my ($event) = @_;
+
+ my $content = $event->{content};
+
+ my $pusher = $content->{pusher}{name};
+ $pusher = $content->{commits}[0]{author}{username} . '(?)'
+ if $pusher eq 'none'; # XXX ?
+ my $commits = @{ $content->{commits} };
+ my $repo = $content->{repository}{name};
+ (my $branch = $content->{ref}) =~ s{^refs/heads/}{};
+ my $compare = $content->{compare};
+ my $commit_messages = join(' / ', map { $_->{message} }
+ @{ $content->{commits} });
+
+ my $msg = "[github] $pusher pushed $commits commit"
+ . ($commits == 1 ? '' : 's')
+ . " to $repo/$branch ($compare): $commit_messages";
+
+ $self->_say_to_channel($msg);
+}
+
+sub flowdock_unknown_inbox_event {
+ my $self = shift;
+ my ($event) = @_;
+
+ warn "unknown timeline event type $event->{event}: " . encode_json($event);
+ $self->_say_to_channel("[$event->{event}] unknown");
+}
+
sub said {
my $self = shift;
my ($args) = @_;