App-Maisha
view release on metacpan or search on metacpan
lib/App/Maisha/Shell.pm view on Meta::CPAN
my %max = (
user_timeline => { limit => 3200, count => 200 }, # specific user timelines
search_tweets => { limit => 800, count => 100 }, # search lists
home_timeline => { limit => 800, count => 200 }, # generic timelines
user_lists => { limit => 5000, count => 5000 }, # user lists
);
#----------------------------------------------------------------------------
# Accessors
sub networks { shift->_elem('networks', @_) }
sub prompt_str { shift->_elem('prompt_str', @_) }
sub tag_str { shift->_elem('tag_str', @_) }
sub order { shift->_elem('order', @_) }
sub limit { shift->_elem('limit', @_) }
sub services { shift->_elem('services', @_) }
sub pager { shift->_elem('pager', @_) }
sub format { shift->_elem('format', @_) }
sub chars { shift->_elem('chars', @_) }
sub history { shift->_elem('historyfile', @_) }
sub debug { shift->_elem('debug', @_) }
sub error { shift->_elem('error', @_) }
#----------------------------------------------------------------------------
# Public API
#
# Connect/Disconnect
#
sub connect {
my ($self,$plug,$config) = @_;
unless($plug) { warn "No plugin supplied\n"; return }
$self->_load_plugins unless(%plugins);
my $plugin = $self->_get_plugin($plug);
if(!$plugin) {
warn "Unable to establish plugin '$plug'\n";
return;
}
my $status = $plugin->login($config);
if(!$status) {
warn "Login to '$plug' failed\n";
return;
}
my $services = $self->services;
push @$services, $plugin;
$self->services($services);
$self->_reset_networks;
}
*run_connect = \&connect;
sub smry_connect { "connect to a service" }
sub help_connect {
<<'END';
Connects to a named service. Requires the name of the service, together with
the username and password to access the service.
END
}
sub run_disconnect {
my ($self,$plug) = @_;
unless($plug) { warn "No plugin supplied\n"; return }
my $services = $self->services;
my @new = grep {ref($_) !~ /^App::Maisha::Plugin::$plug$/} @$services;
$self->services(\@new);
$self->_reset_networks;
}
sub smry_disconnect { "disconnect from a service" }
sub help_disconnect {
<<'END';
Disconnects from the named service.
END
}
#
# Use
#
sub run_use {
my ($self,$plug) = @_;
if(my $p = $self->_get_plugin($plug)) {
my $services = $self->services;
my @new = grep {ref($_) !~ /^App::Maisha::Plugin::$plug$/} @$services;
unshift @new, $self->_get_plugin($plug);
$self->services(\@new);
$self->_reset_networks;
} else {
warn "Unknown plugin\n";
}
}
sub smry_use { "set primary service" }
sub help_use {
<<'END';
Set the primary service for message list commands.
END
}
sub comp_use {
my ($self, $word, $line, $start_index) = @_;
my $services = $self->services;
my @networks = map {
ref($_) =~ /^App::Maisha::Plugin::(.+)/; $1;
} @$services;
return grep { /^$word/ } @networks;
}
#
# Followers
#
( run in 0.939 second using v1.01-cache-2.11-cpan-97f6503c9c8 )