From 7236bfc89b1176c9ff772b589dcf12e28f5aae0e Mon Sep 17 00:00:00 2001 From: Ryan Voots Date: Mon, 7 Jun 2021 11:12:26 -0400 Subject: [PATCH] Update readme to remove freenode mention --- README.pod | 2 -- etc/bb3.conf | 57 ++++++++++-------------------- etc/plugins.conf | 84 ++++++++++++++++++++++++++++++++------------ plugins/factoids.pm | 3 ++ plugins/supereval.pm | 4 +-- plugins/translate.pm | 27 ++++++++------ 6 files changed, 102 insertions(+), 75 deletions(-) diff --git a/README.pod b/README.pod index 84fc767..afd351c 100644 --- a/README.pod +++ b/README.pod @@ -13,8 +13,6 @@ This is the source code for perlbot, the resident infobot on Freenode’s =over 4 -=item * L - =item * L =back diff --git a/etc/bb3.conf b/etc/bb3.conf index 0d6eb1a..7af26b2 100644 --- a/etc/bb3.conf +++ b/etc/bb3.conf @@ -37,47 +37,11 @@ http_plugin_port 1092 - channel \#buubot - channel \#\#turtles - channel \#perlcafe - channel \#webgui - channel \#citadel - channel \#modperl - channel \#perl - channel \#ipv6 - channel \#perlbot - channel \#mrtg - channel \#ipv6-fr - channel \#freebsd-fr - channel \#botpark - channel \#css - channel \#modus - channel \#perl-cats - channel \#cout.dev - channel \#web-locals - channel \#regex - channel \#regexen - channel \#mojo - - ignore buubot - ignore avarbot - ignore jeval - ignore gumbybrain - ignore perlbot - ignore buubot3 - ignore loudbot - ignore serfbot - ignore farnsworth - ignore frogbot - ignore EvanCarroll - ignore EvanCarrol - ignore EvanCaroll - ignore EvanCarol - ignore EC + channel \#\#perl server 192.168.32.1 username perlbot - password sindarin + password UjecyickehumBevGixrejparpheyndoc port 65432 root_mask p3m/member/simcop2387 @@ -122,3 +86,20 @@ http_plugin_port 1092 port 65432 root_mask ~simcop238@simcop2387.info + + + channel \#buubot + channel \#perl + channel \#perlbot + channel \#botpark + channel \#perl-cats + + server 192.168.32.1 + username perlbot-libera + password AtlyeSlognakjabDatCujatyijFeach9 + port 65432 + root_mask perlbot/patrician/simcop2387 + + ignore lambdabot + ignore lambdabot2 + diff --git a/etc/plugins.conf b/etc/plugins.conf index 57f7ad8..814ab6f 100644 --- a/etc/plugins.conf +++ b/etc/plugins.conf @@ -1,7 +1,7 @@ server "*" { channel "*" { plugin "*" { addressed: true } - plugin "join" { access: op; addressed: true } + plugin "join" { access: root; addressed: true } plugin "allowpaste" { access: op; addressed: true } plugin "pastebinadmin" { access: op; addressed: true } plugin "part" { access: op } @@ -13,6 +13,16 @@ server "*" { plugin "karma_modify" { addressed: false; } plugin "seen" {addressed: false; } } + channel "##perl" { + plugin "factoids" { + addressed: false; + } + plugin "eval" {addressed: true; } + plugin "deparse" {addressed: true; } + plugin "perldoc" {addressed: true; } + plugin "corelist" {addressed: true; } + plugin "default" {plugin: "factoids";} + } channel "#pdl" { plugin "eval" {addressed: false; } plugin "deparse" {addressed: false; } @@ -54,6 +64,24 @@ server "*" { plugin "eval" {addressed: false; } plugin "deparse" {addressed: false; } } + channel "#regex" { + plugin "factoids" { + addressed: false; + } + plugin "default" {plugin: "factoids"; } + } + channel "#regexen" { + plugin "factoids" { + addressed: false; + } + plugin "default" {plugin: "factoids"; } + } + channel "#reg3x" { + plugin "factoids" { + addressed: false; + } + plugin "default" {plugin: "factoids"; } + } } server "discord.gg" { channel "*" { @@ -69,12 +97,34 @@ server "matrix.org" { } } server "*.freenode.net" { + channel { + plugin "*" { addressed: true } + plugin "join" { access: root; addressed: true } + plugin "allowpaste" { access: op; addressed: true } + plugin "pastebinadmin" { access: op; addressed: true } + plugin "part" { access: op } + plugin "reload_plugins" { access: root } + plugin "restart" { access: root } + plugin "conf_dump" { access: root; } + plugin "save_config" { access: root; } + plugin "conf" { access: root; } + plugin "karma_modify" { addressed: false; } + plugin "seen" {addressed: false; } + } + channel "##perl" { + plugin "factoids" { + addressed: false; + } + plugin "default" {plugin: "factoids";} + plugin "eval" {addressed: true; } + plugin "deparse" {addressed: true; } + plugin "perldoc" {addressed: true; } + plugin "corelist" {addressed: true; } + } +} +server "*.libera.chat" { channel "#perlbot" { plugin "factoids" { - namespaced: true; - prefix_command: "!"; - chanspace: "#perlbot"; - serverspace: "freenode.net"; filtersep: true; addressed: false; } @@ -83,31 +133,19 @@ 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: "!"; - filtersep: true; } plugin "default" {plugin: "factoids"; } } - channel "#lpmc" { - plugin "eval" {addressed: false; } - plugin "deparse" {addressed: false; } + channel "#reg3x" { + plugin "factoids" { + addressed: false; + } + plugin "default" {plugin: "factoids"; } } - channel "#learnprogramming" { - plugin "eval" {addressed: false; } - plugin "deparse" {addressed: false; } - } -} +} diff --git a/plugins/factoids.pm b/plugins/factoids.pm index 87361ca..bf78d9c 100644 --- a/plugins/factoids.pm +++ b/plugins/factoids.pm @@ -224,7 +224,10 @@ sub handle ($self, $said, $pm) { $said->{body} =~ s/^\s*(what|who|where|how|when|why)\s+($COPULA_RE)\s+(?.*?)\??\s*$/$+{fact}/i; + my $prefix = $conf->{command_prefix}; + + warn "Checking for prefix: $prefix in ".Dumper($conf); return unless $prefix; $said->{nosuggest} = 1; diff --git a/plugins/supereval.pm b/plugins/supereval.pm index 9c79d99..9d76b7e 100644 --- a/plugins/supereval.pm +++ b/plugins/supereval.pm @@ -62,7 +62,7 @@ sub make_pastebin_all { } } -my @versions = ('', 't', qw(1 2 3 4 5.0 5.1 5.2 5.3 5.4 5.5 tall all rall yall), map {$_, $_."t"} qw/5.6 5.8 5.8.4 5.8.8 5.10 5.10.0 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26 5.28 5.32 5.32.1 5.32.0 5.30 5.30.3 5.30.2 5.30.1 5.30.0 5.28.2 5.28.1 5.28.0 5.26.3 5.26.2 5.26.1 5.26.0 5.24.4 5.24.3 5.24.2 5.24.1 5.24.0 5.22.4 5.22.3 5.22.2 5.22.1 5.22.0 5.20.3 5.20.2 5.20.1 5.20.0 5.18.4 5.18.3 5.18.2 5.18.1 5.18.0 5.16.3 5.16.2 5.16.1 5.16.0 5.14.4 5.14.3 5.14.2 5.14.1 5.14.0 5.12.5 5.12.4 5.12.3 5.12.2 5.12.1 5.12.0 5.10.1 5.10.0 5.8.9 5.8.8 5.8.7 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.6.2 5.6.1 5.6.0/); +my @versions = ('', 't', qw(1 2 3 4 5.0 5.1 5.2 5.3 5.4 5.5 tall all rall yall), map {$_, $_."t"} qw/5.6 5.8 5.8.4 5.8.8 5.10 5.10.0 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26 5.28 5.32 5.32.1 5.32.0 5.34.0 5.34 5.30 5.30.3 5.30.2 5.30.1 5.30.0 5.28.2 5.28.1 5.28.0 5.26.3 5.26.2 5.26.1 5.26.0 5.24.4 5.24.3 5.24.2 5.24.1 5.24.0 5.22.4 5.22.3 5.22.2 5.22.1 5.22.0 5.20.3 5.20.2 5.20.1 5.20.0 5.18.4 5.18.3 5.18.2 5.18.1 5.18.0 5.16.3 5.16.2 5.16.1 5.16.0 5.14.4 5.14.3 5.14.2 5.14.1 5.14.0 5.12.5 5.12.4 5.12.3 5.12.2 5.12.1 5.12.0 5.10.1 5.10.0 5.8.9 5.8.8 5.8.7 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.6.2 5.6.1 5.6.0/); sub new { my( $class ) = @_; @@ -173,7 +173,7 @@ sub command { # we were addressed, but not nested, in #perl6. Switch to perl6, otherwise use perl5 if ($said->{channel} eq "#pdl" && !$said->{nested} && $orig_type =~ /^[ws]*$/) { - $type = "perl5.32" + $type = "perl5.34" } if ($command eq 'r' && (!$said->{addressed} && !$said->{nested} && ($said->{channel} ne "#perl6" && $said->{channel} eq '#raku'))) { diff --git a/plugins/translate.pm b/plugins/translate.pm index 62760f1..ffe360e 100644 --- a/plugins/translate.pm +++ b/plugins/translate.pm @@ -1,23 +1,30 @@ use strict; use warnings; -#use Bing::Translate; +use LWP::UserAgent; +use JSON::MaybeXS qw/decode_json encode_json/; +use Data::Dumper; +my $ua = LWP::UserAgent->new(); return sub { my( $said ) = @_; -open(my $fh, "; -chomp $secret; -close($fh); - -my $tro = Bing::Translate->new($cid, $secret); if ($said->{body} =~ /^\s*(?\S+)\s+(?\S+)\s+(?.*)$/) { -# print $secret; - print $tro->translate($+{text}, $+{from}, $+{to}); + my $json = { + source_language => $+{from}, + target_language => $+{to}, + text => $+{text} + }; + + my $resp = $ua->post("http://192.168.1.229:10000/translate_text", Content => encode_json($json)); + + my $cont = $resp->decoded_content(); + my $output = decode_json($cont); + + print Dumper $output; + } else { print "help text"; }