3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-29 23:39:24 +01:00

Progress on polishing things

This commit is contained in:
Pragmatic Software 2021-07-23 18:26:45 -07:00
parent 6fd4245b2e
commit 2b0201343f
8 changed files with 40 additions and 18 deletions

View File

@ -17,7 +17,11 @@ sub initialize {
my $filename = $conf{filename} // $self->{pbot}->{registry}->get_value('general', 'data_dir') . '/capabilities';
# capabilities hash table
$self->{caps} = PBot::Storage::HashObject->new(name => 'Capabilities', filename => $filename, pbot => $self->{pbot});
$self->{caps} = PBot::Storage::HashObject->new(
pbot => $self->{pbot},
name => 'Capabilities',
filename => $filename,
);
# load capabilities
$self->{caps}->load;

View File

@ -12,7 +12,13 @@ use PBot::Imports;
sub initialize {
my ($self, %conf) = @_;
$self->{storage} = PBot::Storage::HashObject->new(pbot => $self->{pbot}, name => 'Channels', filename => $conf{filename});
$self->{storage} = PBot::Storage::HashObject->new(
pbot => $self->{pbot},
name => 'Channels',
filename => $conf{filename}
);
$self->{storage}->load;
}
@ -25,6 +31,7 @@ sub join {
foreach my $channel (split /,/, $channels) {
$channel = lc $channel;
$self->{pbot}->{event_dispatcher}->dispatch_event('pbot.join', {channel => $channel});
delete $self->{pbot}->{chanops}->{is_opped}->{$channel};

View File

@ -65,7 +65,11 @@ sub initialize {
$self->{pbot} = $self->{pbot};
$self->{storage} = PBot::Storage::DualIndexSQLiteObject->new(name => 'Factoids', filename => $filename, pbot => $self->{pbot});
$self->{storage} = PBot::Storage::DualIndexSQLiteObject->new(
pbot => $self->{pbot},
name => 'Factoids',
filename => $filename,
);
$self->{pbot}->{registry}->add_default('text', 'factoids', 'default_rate_limit', 15);
$self->{pbot}->{registry}->add_default('text', 'factoids', 'max_name_length', 100);
@ -1144,7 +1148,7 @@ sub interpreter {
# if multiple channels have this keyword, then ask user to disambiguate
if (@chanlist> 1) {
return undef if $context->{referenced};
return undef if $context->{embedded};
return $ref_from . "Factoid `$original_keyword` exists in " . join(', ', @chanlist) . "; use `fact <channel> $original_keyword` to choose one.";
}
@ -1170,7 +1174,7 @@ sub interpreter {
# found factfind matches
if ($matches !~ m/^No factoids/) {
return undef if $context->{referenced};
return undef if $context->{embedded};
return "No such factoid '$original_keyword'; $matches";
}
@ -1184,7 +1188,7 @@ sub interpreter {
# /msg the caller if nothing similiar was found
$context->{send_msg_to_caller} = 1 if $matches eq 'none';
$context->{send_msg_to_caller} = 1 if $context->{referenced};
$context->{send_msg_to_caller} = 1 if $context->{embedded};
my $msg_caller = '';
$msg_caller = "/msg $context->{nick} " if $context->{send_msg_to_caller};
@ -1210,7 +1214,7 @@ sub interpreter {
$context->{channel_name} = $channel_name;
$context->{trigger_name} = $trigger_name;
return undef if $context->{referenced} and $self->{storage}->get_data($channel, $keyword, 'noembed');
return undef if $context->{embedded} and $self->{storage}->get_data($channel, $keyword, 'noembed');
if ($self->{storage}->get_data($channel, $keyword, 'locked_to_channel')) {
if ($context->{ref_from} ne "") { # called from another channel

View File

@ -15,16 +15,14 @@ use PBot::Utils::LoadModules qw/load_modules/;
sub initialize {
my ($self, %conf) = @_;
# register all the handlers in the Handlers directory
$self->register_handlers(%conf);
# load the handlers in the Handlers directory
$self->load_handlers(%conf);
}
# registers all the handler files in the Handlers directory
sub register_handlers {
sub load_handlers {
my ($self, %conf) = @_;
$self->{pbot}->{logger}->log("Registering handlers:\n");
$self->{pbot}->{logger}->log("Loading handlers:\n");
load_modules($self, 'PBot::Core::Handlers');
}

View File

@ -214,7 +214,7 @@ sub process_line {
}
# set $context object's embedded flag
$context->{referenced} = $embedded;
$context->{embedded} = $embedded;
# interpret all parsed commands
foreach $command (@commands) {

View File

@ -171,8 +171,8 @@ sub process_pipe_reader {
$context->{result} = "No output.";
}
# don't output unnecessary result if command was referenced within a message
if ($context->{referenced}) {
# don't output unnecessary result if command was embedded within a message
if ($context->{embedded}) {
return if $context->{result} =~ m/(?:no results)/i;
}

View File

@ -18,7 +18,11 @@ sub initialize {
my $filename = $conf{filename} // Carp::croak("Missing filename configuration item in " . __FILE__);
# registry is stored as a dual-index hash object
$self->{storage} = PBot::Storage::DualIndexHashObject->new(name => 'Registry', filename => $filename, pbot => $self->{pbot});
$self->{storage} = PBot::Storage::DualIndexHashObject->new(
pbot => $self->{pbot},
name => 'Registry',
filename => $filename,
);
# registry triggers are processed when a registry entry is modified
$self->{triggers} = {};

View File

@ -13,7 +13,12 @@ use PBot::Imports;
sub initialize {
my ($self, %conf) = @_;
$self->{storage} = PBot::Storage::HashObject->new(name => 'Users', filename => $conf{filename}, pbot => $conf{pbot});
$self->{storage} = PBot::Storage::HashObject->new(
pbot => $conf{pbot},
name => 'Users',
filename => $conf{filename},
);
$self->{user_index} = {};
$self->{user_cache} = {};