1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 22:55:40 -04:00

Fix bug in channels sharing namespace.

This commit is contained in:
Ryan Voots 2016-12-31 00:51:42 -05:00
parent 422ace207c
commit 377fe7d9d5
3 changed files with 29 additions and 7 deletions

View file

@ -55,6 +55,8 @@ http_plugin_port 1092
channel \#perl-cats channel \#perl-cats
channel \#cout.dev channel \#cout.dev
channel \#web-locals channel \#web-locals
channel \#regex
channel \#regexen
ignore buubot ignore buubot
ignore avarbot ignore avarbot

View file

@ -45,8 +45,21 @@ server "*.freenode.net" {
channel "#regex" { channel "#regex" {
plugin "factoids" { plugin "factoids" {
addressed: false; addressed: false;
namespaced: true;
chanspace: "#regex";
serverspace: "freenode.net";
prefix_command: "!";
filtersep: true;
}
plugin "default" {plugin: "factoids"; }
}
channel "#regexen" {
plugin "factoids" {
addressed: false;
namespaced: true;
chanspace: "#regex";
serverspace: "freenode.net";
prefix_command: "!"; prefix_command: "!";
plugins: false;
filtersep: true; filtersep: true;
} }
plugin "default" {plugin: "factoids"; } plugin "default" {plugin: "factoids"; }

View file

@ -78,7 +78,7 @@ sub get_conf_for_channel {
my $gc = sub {$pm->plugin_conf($_[0], $server, $channel)}; my $gc = sub {$pm->plugin_conf($_[0], $server, $channel)};
# Load factoids if it exists, otherwise grab the old nfacts setup # Load factoids if it exists, otherwise grab the old nfacts setup
my $conf = $gc->("factoids") // $gc->("nfacts"); my $conf = $gc->("factoids");
return $conf; return $conf;
} }
@ -93,23 +93,30 @@ sub get_namespaced_factoid {
return $body if $channel eq '*irc_msg' or $channel eq '##NULL'; return $body if $channel eq '*irc_msg' or $channel eq '##NULL';
warn "NAMESPACE: [ $channel , $server ]"; open(my $fh, ">/tmp/notwut");
my $conf = $self->get_conf_for_channel($pm, $server, $channel); print $fh "NAMESPACE: [ $channel , $server ]";
warn Dumper($conf); my $conf = $self->get_conf_for_channel($pm, $said->{server}, $channel);
print $fh Dumper($conf);
my $realserver = $conf->{serverspace} // $server; my $realserver = $conf->{serverspace} // $server;
my $realchannel = $conf->{chanspace} // $channel; my $realchannel = $conf->{chanspace} // $channel;
print $fh Dumper($realserver, $realchannel);
my $sepbody = $fsep.join($fsep, ($realserver, $realchannel, $body)); my $sepbody = $fsep.join($fsep, ($realserver, $realchannel, $body));
print $fh $sepbody, "\n";
return $sepbody; return $sepbody;
} }
sub namespace_filter { sub namespace_filter {
my ($self, $body, $enabled) = @_; my ($self, $body, $enabled) = @_;
return $body =~ s|$fsep[^$fsep]*?$fsep[^$fsep]*?$fsep(\S+)(?=\s)|$1|rg if $enabled; return $body =~ s|$fsep[^$fsep]*?$fsep[^$fsep]*?$fsep(\S+)|$1|rg if $enabled;
$body; $body;
} }