diff options
-rw-r--r-- | lib/Bot/Flowdock/IRC.pm | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/Bot/Flowdock/IRC.pm b/lib/Bot/Flowdock/IRC.pm index e0e80ea..fb9c1ea 100644 --- a/lib/Bot/Flowdock/IRC.pm +++ b/lib/Bot/Flowdock/IRC.pm @@ -12,10 +12,19 @@ extends 'Bot::BasicBot'; sub FOREIGNBUILDARGS { my $class = shift; my (%args) = @_; - delete $args{$_} for qw(token key organization flow); + delete $args{$_} for qw(email token key organization flow); return %args; } +# XXX require this for now so that we can tell which account is the bot +# (to allow us to filter those out so we don't get echos) +# ideally, there would be a better way to detect this +has email => ( + is => 'ro', + isa => 'Str', + required => 1, +); + has token => ( is => 'ro', isa => 'Str', @@ -76,6 +85,11 @@ has _id_map => ( }, ); +has _my_id => ( + is => 'rw', + isa => 'Int', +); + sub connected { my $self = shift; @@ -86,6 +100,9 @@ sub connected { for my $user (@{ $flow->body->{users} }) { $self->_set_name_for_id($user->{id}, $user->{nick}); + if ($user->{email} eq $self->email) { + $self->_my_id($user->{id}); + } } } @@ -97,6 +114,8 @@ sub tick { last unless $event; + next if $event->{user} == $self->_my_id; + my $type = $event->{event}; if ($type eq 'message' || $type eq 'line') { |