summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-02-16 21:15:07 -0600
committerJesse Luehrs <doy@tozt.net>2012-02-16 21:15:07 -0600
commit2ddc43d06500224548f2ad3e5419f4316406adcf (patch)
tree2e9b367d9366a00b7efa00731549b104604f2c4a
parent9dccd541a5d22a3418da6084d76ca4cab98c6f59 (diff)
downloadbot-flowdock-irc-2ddc43d06500224548f2ad3e5419f4316406adcf.tar.gz
bot-flowdock-irc-2ddc43d06500224548f2ad3e5419f4316406adcf.zip
refactor event types out into separate methods
-rw-r--r--lib/Bot/Flowdock/IRC.pm26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/Bot/Flowdock/IRC.pm b/lib/Bot/Flowdock/IRC.pm
index bd0a8c3..e3b8732 100644
--- a/lib/Bot/Flowdock/IRC.pm
+++ b/lib/Bot/Flowdock/IRC.pm
@@ -103,21 +103,31 @@ sub tick {
my $event = $self->flowdock_stream->get_next_event;
last unless $event;
- next unless $event->{event} eq 'message';
- # skip if this is a message that we just sent
- next if exists $event->{external_user_name};
+ my $type = $event->{event};
- my $name = $self->name_from_id($event->{user});
- $self->say(
- channel => ($self->channels)[0],
- body => "<$name> $event->{content}",
- );
+ if ($type eq 'message') {
+ $self->flowdock_message($event);
+ }
}
return 1;
}
+sub flowdock_message {
+ my $self = shift;
+ my ($event) = @_;
+
+ # skip if this is a message that we just sent
+ return if exists $event->{external_user_name};
+
+ my $name = $self->name_from_id($event->{user});
+ $self->say(
+ channel => ($self->channels)[0],
+ body => "<$name> $event->{content}",
+ );
+}
+
sub said {
my $self = shift;
my ($args) = @_;