1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 10:45: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 \#cout.dev
channel \#web-locals
channel \#regex
channel \#regexen
ignore buubot
ignore avarbot

View file

@ -45,8 +45,21 @@ server "*.freenode.net" {
channel "#regex" {
plugin "factoids" {
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: "!";
plugins: false;
filtersep: true;
}
plugin "default" {plugin: "factoids"; }

View file

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