diff --git a/etc/bb3.conf b/etc/bb3.conf index f88095a..4e43c41 100644 --- a/etc/bb3.conf +++ b/etc/bb3.conf @@ -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 diff --git a/etc/plugins.conf b/etc/plugins.conf index 0c09407..56a4512 100644 --- a/etc/plugins.conf +++ b/etc/plugins.conf @@ -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"; } diff --git a/plugins/factoids.pm b/plugins/factoids.pm index fa25856..1168ce6 100644 --- a/plugins/factoids.pm +++ b/plugins/factoids.pm @@ -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; }