Skip to content

Commit

Permalink
Added commands to add/remove users from lists
Browse files Browse the repository at this point in the history
  • Loading branch information
semifor committed May 5, 2012
1 parent 4cf458a commit a94f22a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions lib/POE/Component/Server/Twirc.pm
Expand Up @@ -313,6 +313,7 @@ sub twitter {
if ( blessed $_ && $_->can('code') && $_->code == 502 ) {
$_ = 'Fail Whale';
}
s/ at .* line \d+//;
$self->twitter_error("$method -> $_");
undef;
};
Expand Down Expand Up @@ -1426,6 +1427,44 @@ event report_spam_helper => sub {
$self->twitter(report_spam => { screen_name => $spammer });
};

=item add I<screen_name> to I<list-slug>
Add a user to one of your lists.
=cut

event cmd_add => sub { $_[OBJECT]->_add_remove_list_member(qw/add to/, @_[ARG0, ARG1]) };

sub _add_remove_list_member {
my ( $self, $verb, $preposition, $channel, $args ) = @_;

my ( $nick, $slug ) = ($args || '') =~ /
^@?(\w+) # nick; strip leading @ if there is one
\s+$preposition\s+
([-\w]+) # the list-slug
\s*$
/x;

unless ( defined $nick ) {
$self->bot_says($channel, "usage: $verb <nick> $preposition <list-slug>");
return;
}

$self->twitter($verb . '_list_member' => {
owner_id => $self->twitter_id,
slug => $slug,
screen_name => $nick,
});
};

=item remove I<screen_name> from I<list-slug>
Add a user to one of your lists.
=cut

event cmd_remove => sub { $_[OBJECT]->_add_remove_list_member(qw/remove from/, @_[ARG0, ARG1]) };

=item help
Display a simple help message
Expand Down

0 comments on commit a94f22a

Please sign in to comment.