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:
parent
6fd4245b2e
commit
2b0201343f
@ -17,7 +17,11 @@ sub initialize {
|
|||||||
my $filename = $conf{filename} // $self->{pbot}->{registry}->get_value('general', 'data_dir') . '/capabilities';
|
my $filename = $conf{filename} // $self->{pbot}->{registry}->get_value('general', 'data_dir') . '/capabilities';
|
||||||
|
|
||||||
# capabilities hash table
|
# 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
|
# load capabilities
|
||||||
$self->{caps}->load;
|
$self->{caps}->load;
|
||||||
|
@ -12,7 +12,13 @@ use PBot::Imports;
|
|||||||
|
|
||||||
sub initialize {
|
sub initialize {
|
||||||
my ($self, %conf) = @_;
|
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;
|
$self->{storage}->load;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +31,7 @@ sub join {
|
|||||||
|
|
||||||
foreach my $channel (split /,/, $channels) {
|
foreach my $channel (split /,/, $channels) {
|
||||||
$channel = lc $channel;
|
$channel = lc $channel;
|
||||||
|
|
||||||
$self->{pbot}->{event_dispatcher}->dispatch_event('pbot.join', {channel => $channel});
|
$self->{pbot}->{event_dispatcher}->dispatch_event('pbot.join', {channel => $channel});
|
||||||
|
|
||||||
delete $self->{pbot}->{chanops}->{is_opped}->{$channel};
|
delete $self->{pbot}->{chanops}->{is_opped}->{$channel};
|
||||||
|
@ -65,7 +65,11 @@ sub initialize {
|
|||||||
|
|
||||||
$self->{pbot} = $self->{pbot};
|
$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', 'default_rate_limit', 15);
|
||||||
$self->{pbot}->{registry}->add_default('text', 'factoids', 'max_name_length', 100);
|
$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 multiple channels have this keyword, then ask user to disambiguate
|
||||||
if (@chanlist> 1) {
|
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.";
|
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
|
# found factfind matches
|
||||||
if ($matches !~ m/^No factoids/) {
|
if ($matches !~ m/^No factoids/) {
|
||||||
return undef if $context->{referenced};
|
return undef if $context->{embedded};
|
||||||
return "No such factoid '$original_keyword'; $matches";
|
return "No such factoid '$original_keyword'; $matches";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1184,7 +1188,7 @@ sub interpreter {
|
|||||||
|
|
||||||
# /msg the caller if nothing similiar was found
|
# /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 $matches eq 'none';
|
||||||
$context->{send_msg_to_caller} = 1 if $context->{referenced};
|
$context->{send_msg_to_caller} = 1 if $context->{embedded};
|
||||||
|
|
||||||
my $msg_caller = '';
|
my $msg_caller = '';
|
||||||
$msg_caller = "/msg $context->{nick} " if $context->{send_msg_to_caller};
|
$msg_caller = "/msg $context->{nick} " if $context->{send_msg_to_caller};
|
||||||
@ -1210,7 +1214,7 @@ sub interpreter {
|
|||||||
$context->{channel_name} = $channel_name;
|
$context->{channel_name} = $channel_name;
|
||||||
$context->{trigger_name} = $trigger_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 ($self->{storage}->get_data($channel, $keyword, 'locked_to_channel')) {
|
||||||
if ($context->{ref_from} ne "") { # called from another channel
|
if ($context->{ref_from} ne "") { # called from another channel
|
||||||
|
@ -15,16 +15,14 @@ use PBot::Utils::LoadModules qw/load_modules/;
|
|||||||
sub initialize {
|
sub initialize {
|
||||||
my ($self, %conf) = @_;
|
my ($self, %conf) = @_;
|
||||||
|
|
||||||
# register all the handlers in the Handlers directory
|
# load the handlers in the Handlers directory
|
||||||
$self->register_handlers(%conf);
|
$self->load_handlers(%conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
# registers all the handler files in the Handlers directory
|
sub load_handlers {
|
||||||
|
|
||||||
sub register_handlers {
|
|
||||||
my ($self, %conf) = @_;
|
my ($self, %conf) = @_;
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log("Registering handlers:\n");
|
$self->{pbot}->{logger}->log("Loading handlers:\n");
|
||||||
load_modules($self, 'PBot::Core::Handlers');
|
load_modules($self, 'PBot::Core::Handlers');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ sub process_line {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# set $context object's embedded flag
|
# set $context object's embedded flag
|
||||||
$context->{referenced} = $embedded;
|
$context->{embedded} = $embedded;
|
||||||
|
|
||||||
# interpret all parsed commands
|
# interpret all parsed commands
|
||||||
foreach $command (@commands) {
|
foreach $command (@commands) {
|
||||||
|
@ -171,8 +171,8 @@ sub process_pipe_reader {
|
|||||||
$context->{result} = "No output.";
|
$context->{result} = "No output.";
|
||||||
}
|
}
|
||||||
|
|
||||||
# don't output unnecessary result if command was referenced within a message
|
# don't output unnecessary result if command was embedded within a message
|
||||||
if ($context->{referenced}) {
|
if ($context->{embedded}) {
|
||||||
return if $context->{result} =~ m/(?:no results)/i;
|
return if $context->{result} =~ m/(?:no results)/i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,11 @@ sub initialize {
|
|||||||
my $filename = $conf{filename} // Carp::croak("Missing filename configuration item in " . __FILE__);
|
my $filename = $conf{filename} // Carp::croak("Missing filename configuration item in " . __FILE__);
|
||||||
|
|
||||||
# registry is stored as a dual-index hash object
|
# 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
|
# registry triggers are processed when a registry entry is modified
|
||||||
$self->{triggers} = {};
|
$self->{triggers} = {};
|
||||||
|
@ -13,7 +13,12 @@ use PBot::Imports;
|
|||||||
sub initialize {
|
sub initialize {
|
||||||
my ($self, %conf) = @_;
|
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_index} = {};
|
||||||
$self->{user_cache} = {};
|
$self->{user_cache} = {};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user