commit - 38334f68ad2bb6f935513f481a8af6786797594a
commit + 731127fc2f8eb6e363d5aed54f26050229b14c70
blob - ff2df436c956bc21160f1837c8f91c7df654b8a1
blob + 09c129831bc7593b34bed9ae7164f6d2638878b9
--- BNC.pm
+++ BNC.pm
use warnings;
use OpenBSD::Pledge;
use OpenBSD::Unveil;
-use MIME::Base64;
-use Digest::SHA qw(sha256_hex);
use lib './';
require "SQLite.pm";
require "Hash.pm";
# File containing IRC networks
my $netpath = "networks";
my @networks;
-#my $zncconfpath = $conf{zncconfpath} || "$zncdir/.znc/configs/znc.conf";
-my $znctree = { Node => "root" };
use constant {
NONE => 0,
ALL => 3,
};
-`doas chown znc:daemon /home/znc/home/znc/.znc/configs/znc.conf`;
`doas chmod g+r /home/znc/home/znc/.znc/`;
-#my @zncconf = main::readarray($zncconfpath);
-#$znctree;
my @users;
-#foreach my $line (@zncconf) {
-# if ($line =~ /<User (.*)>/) {
-# push(@users, $1);
-# }
-#}
-#$znctree = parseml($znctree, @zncconf);
main::cbind("pub", "-", "bnc", \&mbnc);
main::cbind("msg", "-", "bnc", \&mbnc);
main::cbind("msg", "-", "regex", \&mregex);
}
sub init {
- #znc.conf file
- #unveil("$zncconfpath", "r") or die "Unable to unveil $!";
- #dependencies for figlet
unveil("/usr/local/bin/figlet", "rx") or die "Unable to unveil $!";
unveil("/usr/lib/libc.so.95.1", "r") or die "Unable to unveil $!";
unveil("/usr/libexec/ld.so", "r") or die "Unable to unveil $!";
unveil("/usr/bin/tail", "rx") or die "Unable to unveil $!";
unveil("$netpath", "r") or die "Unable to unveil $!";
- #znc.log file
- #unveil("$znclog", "r") or die "Unable to unveil $!";
- #print treeget($znctree, "AnonIPLimit")."\n";
- #print treeget($znctree, "ServerThrottle")."\n";
- #print treeget($znctree, "ConnectDelay")."\n";
- #print "treeget\n";
- #print Dumper \treeget($znctree, "User", "Node");
- #print Dumper \treeget($znctree, "User", "Network", "Node");
@networks = readnetworks($netpath);
@networks = sort @networks;
}
-# parseml($tree, @lines)
-# tree is a reference to a hash
-# returns hash ref of tree
-sub parseml {
- my ($tree, @lines) = @_;
- #if (scalar(@lines) == 0) { return $tree; }
- while (scalar(@lines) > 0) {
- my $line = shift(@lines);
- if ($line =~ /^\s*([^=<>\s]+)\s*=\s*([^=<>]+)\s*$/) {
- my ($tag, $val) = ($1, $2);
- $tree->{$tag} = $val;
- } elsif ($line =~ /^\/\//) { # skip comments
- } elsif ($line =~ /^\s*$/) { # skip blank lines
- } elsif ($line =~ /^\s*<([^>\s\/]+)\s*([^>\/]*)>\s*$/) {
- my ($tag, $val) = ($1, $2);
- if (!defined($tree->{$tag})) { $tree->{$tag} = []; }
- my @newlines;
- while (scalar(@lines) > 0) {
- my $line = shift(@lines);
- if ($line =~ /^\s*<\/$tag>\s*$/) {
- my $subtree = parseml({ Node => $val }, @newlines);
- push(@{$tree->{$tag}}, $subtree);
- return parseml($tree, @lines);
- }
- push(@newlines, $line);
- }
- } else { print "ERROR: $line\n"; }
- #TODO ERRORS not defined??
-# } else { main::debug(ERRORS, "ERROR: $line"); }
- }
- return $tree;
-}
-
-#Returns array of all values
-#treeget($tree, "User");
-sub treeget {
- my ($tree, @keys) = @_;
- my $subtree;
- my @rest = @keys;
- my $key = shift(@rest);
- $subtree = $tree->{$key};
- if (!defined($subtree)) {
- return ("Undefined");
- } elsif (ref($subtree) eq 'HASH') {
- return treeget($subtree, @rest);
- } elsif (ref($subtree) eq 'ARRAY') {
- my @array = @{$subtree};
- my @ret;
- foreach my $hashref (@array) {
- push(@ret, treeget($hashref, @rest));
- }
- return @ret;
- #my @array = @{$subtree};
- #print Dumper treeget($hashref, @rest);
- #print Dumper treeget({$key => $subtree}, @rest);
- #return (treeget($hashref, @rest), treeget({$key => $subtree}, @rest));
- } else {
- return ($subtree);
- }
-}
-
sub mbnc {
my ($bot, $nick, $host, $hand, @args) = @_;
my ($chan, $text);
if ($text =~ /^$/) {
main::putserv($bot, "PRIVMSG $nick :Type !help for new instructions");
foreach my $chan (@teamchans) {
- main::putservlocalnet($bot, "PRIVMSG $chan :Help *$nick* on ".$bot->{name});
+ main::putservlocalnet($bot, "PRIVMSG $chan :Help *$nick* on network ".$bot->{name});
}
return;
} elsif (main::isstaff($bot, $nick) && $text =~ /^delete\s+([[:ascii:]]+)/) {
LoadModule cloneuser controlpanel
LoadModule cloneuser chansaver
EOF
-#LoadModule cloneuser buffextras
main::putserv($bot, "PRIVMSG *controlpanel :$msg");
foreach my $n (@networks) {
my $net = $n->{name};
# sendmsg($bot, "$newnick", "Email sent");
#}
+#`doas chown znc:daemon /home/znc/home/znc/.znc/configs/znc.conf`;
+
# if ($reply =~ /^!resend ([-_0-9a-zA-Z]+) ([-_0-9a-zA-Z]+@[-_0-9a-zA-Z]+\.[-_0-9a-zA-Z]+)$/i) {
# my ($newnick, $email) = ($1, $2);
# my $password = newpass();
#perform Keeps a list of commands to be executed when ZNC connects to IRC.
#webadmin Web based administration module.
+#my $zncconfpath = $conf{zncconfpath} || "$zncdir/.znc/configs/znc.conf";
+#my $znctree = { Node => "root" };
+ #znc.conf file
+ #unveil("$zncconfpath", "r") or die "Unable to unveil $!";
+ #dependencies for figlet
+ #znc.log file
+ #unveil("$znclog", "r") or die "Unable to unveil $!";
+ #print treeget($znctree, "AnonIPLimit")."\n";
+ #print treeget($znctree, "ServerThrottle")."\n";
+ #print treeget($znctree, "ConnectDelay")."\n";
+ #print "treeget\n";
+ #print Dumper \treeget($znctree, "User", "Node");
+ #print Dumper \treeget($znctree, "User", "Network", "Node");
+#my @zncconf = main::readarray($zncconfpath);
+#$znctree;
+#foreach my $line (@zncconf) {
+# if ($line =~ /<User (.*)>/) {
+# push(@users, $1);
+# }
+#}
+#$znctree = parseml($znctree, @zncconf);
+ ## parseml($tree, @lines)
+ ## tree is a reference to a hash
+ ## returns hash ref of tree
+ #sub parseml {
+ # my ($tree, @lines) = @_;
+ # #if (scalar(@lines) == 0) { return $tree; }
+ # while (scalar(@lines) > 0) {
+ # my $line = shift(@lines);
+ # if ($line =~ /^\s*([^=<>\s]+)\s*=\s*([^=<>]+)\s*$/) {
+ # my ($tag, $val) = ($1, $2);
+ # $tree->{$tag} = $val;
+ # } elsif ($line =~ /^\/\//) { # skip comments
+ # } elsif ($line =~ /^\s*$/) { # skip blank lines
+ # } elsif ($line =~ /^\s*<([^>\s\/]+)\s*([^>\/]*)>\s*$/) {
+ # my ($tag, $val) = ($1, $2);
+ # if (!defined($tree->{$tag})) { $tree->{$tag} = []; }
+ # my @newlines;
+ # while (scalar(@lines) > 0) {
+ # my $line = shift(@lines);
+ # if ($line =~ /^\s*<\/$tag>\s*$/) {
+ # my $subtree = parseml({ Node => $val }, @newlines);
+ # push(@{$tree->{$tag}}, $subtree);
+ # return parseml($tree, @lines);
+ # }
+ # push(@newlines, $line);
+ # }
+ # } else { print "ERROR: $line\n"; }
+ # #TODO ERRORS not defined??
+ ## } else { main::debug(ERRORS, "ERROR: $line"); }
+ # }
+ # return $tree;
+ #}
+ #
+ ##Returns array of all values
+ ##treeget($tree, "User");
+ #sub treeget {
+ # my ($tree, @keys) = @_;
+ # my $subtree;
+ # my @rest = @keys;
+ # my $key = shift(@rest);
+ # $subtree = $tree->{$key};
+ # if (!defined($subtree)) {
+ # return ("Undefined");
+ # } elsif (ref($subtree) eq 'HASH') {
+ # return treeget($subtree, @rest);
+ # } elsif (ref($subtree) eq 'ARRAY') {
+ # my @array = @{$subtree};
+ # my @ret;
+ # foreach my $hashref (@array) {
+ # push(@ret, treeget($hashref, @rest));
+ # }
+ # return @ret;
+ # #my @array = @{$subtree};
+ # #print Dumper treeget($hashref, @rest);
+ # #print Dumper treeget({$key => $subtree}, @rest);
+ # #return (treeget($hashref, @rest), treeget({$key => $subtree}, @rest));
+ # } else {
+ # return ($subtree);
+ # }
+ #}
+
+
1; # MUST BE LAST STATEMENT IN FILE
blob - 6f51bbd251c5e01b86dd3b6b666dfba65cc531ef
blob + 6df39f6f4e394386d6b4ef5fb28988e72d15246c
--- Help.pm
+++ Help.pm
}
main::putserv($bot, "PRIVMSG $nick :$msg");
foreach my $chan (@teamchans) {
- main::putservlocalnet($bot, "PRIVMSG $chan :Help *$nick* on ".$bot->{name});
+ main::putservlocalnet($bot, "PRIVMSG $chan :Help *$nick* on network ".$bot->{name});
}
}