Commit Diff
Diff:
c1ac38a6cd6f9a06a88f719deb8a66ad0ce20391
7c35b4be1a5e1156fd25a25b5390b5d6f6ee0f2e
Commit:
7c35b4be1a5e1156fd25a25b5390b5d6f6ee0f2e
Tree:
3f696a3fd5f0ec0cd69503076b7c29d16e181d10
Author:
jrmu <jrmu@ircnow.org>
Committer:
jrmu <jrmu@ircnow.org>
Date:
Fri Oct 23 16:40:42 2020 UTC
Message:
Added parsing for znc.conf
blob - 64294aa2ce6810d4e4d8ebb4343a662a85215143
blob + 848f08a95b24ace8799c882fa5a5457cad38d4b2
--- BNC.pm
+++ BNC.pm
@@ -28,6 +28,14 @@ my $sslport;
my $plainport;
my $mailfrom;
my $mailname;
+use constant {
+ NONE => 0,
+ ERRORS => 1,
+ WARNINGS => 2,
+ ALL => 3,
+};
+my $zncconfpath;
+my $znctree = { Node => "root" };
sub init {
$chans = $main::conf{chans};
@@ -36,6 +44,9 @@ sub init {
$staff = $main::conf{staff};
$zncdir = $main::conf{zncdir};
$znclog = $main::conf{znclog} || "$zncdir/.znc/moddata/adminlog/znc.log";
+ $zncconfpath = $main::conf{zncconfpath} || "$zncdir/.znc/configs/znc.conf";
+ #znc.conf file
+ unveil("$zncconfpath", "r") or die "Unable to unveil $!";
$hostname = $main::conf{hostname};
$terms = $main::conf{terms};
$sslport = $main::conf{sslport};
@@ -48,42 +59,81 @@ sub init {
unveil("/usr/libexec/ld.so", "r") or die "Unable to unveil $!";
#znc.log file
unveil("$znclog", "r") or die "Unable to unveil $!";
- main::cbind("pub", "-", "help", \&help);
- main::cbind("msg", "-", "help", \&help);
- main::cbind("pub", "-", "request", \&help);
main::cbind("pub", "-", "bnc", \&mbnc);
main::cbind("msg", "-", "bnc", \&mbnc);
main::cbind("msg", "-", "regex", \&mregex);
main::cbind("msg", "-", "foreach", \&mforeach);
+ main::cbind("msgm", "-", "*", \&mcontrolpanel);
+ my @zncconf = main::readarray($zncconfpath);
+ $znctree = parseml($znctree, @zncconf);
+ #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");
}
-sub help {
- my ($bot, $nick, $host, $hand, @args) = @_;
- my ($chan, $text);
- my $msg = <<"EOF";
-$terms
-To request a free bouncer, type !bnc <username> <email>. For example, !bnc john john\@example.com.
-EOF
- if ($staff =~ /$nick/) {
- $msg .= <<"EOF";
-To delete a bouncer, type !bnc delete <username>
-To get a list of usernames that match IPs, type !regex ips <ips>
-To get a list of IPs that match usernames, type !regex users <usernames>
-To regex search znc.log and output to the terminal, type !regex <regex>
-EOF
+# 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"); }
}
- if (@args == 2) {
- ($chan, $text) = ($args[0], $args[1]);
- if ($chans =~ $chan) {
- main::putserv($bot, "PRIVMSG $chan :$nick: Please see private message.");
+ return $tree;
+}
+
+#Returns array of all values
+#treeget($tree, "User");
+#treeget($tree, "MaFFia Network");
+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 {
- $text = $args[0];
+ return ($subtree);
}
- main::putserv($bot, "PRIVMSG $nick :$msg");
- foreach my $chan (@teamchans) {
- main::putserv($bot, "PRIVMSG $chan :Help *$nick* on ".$bot->{name});
- }
}
sub mbnc {
@@ -111,6 +161,10 @@ sub mbnc {
}
}
return;
+ } elsif ($staff =~ /$nick/ && $text =~ /^cloneuser$/i) {
+ main::putserv($bot, "PRIVMSG *controlpanel :deluser cloneuser");
+ sleep 3;
+ main::putserv($bot, "PRIVMSG *controlpanel :get Nick cloneuser");
}
### TODO: Check duplicate emails ###
my @rows = SQLite::selectrows("irc", "hostmask", $hostmask);
@@ -151,7 +205,13 @@ sub mbnc {
return;
} elsif ($text =~ /^([[:alnum:]]+)\s+([[:ascii:]]+)/) {
my ($username, $email) = ($1, $2);
- # my $captcha = join'', map +(0..9,'a'..'z','A'..'Z')[rand(10+26*2)], 1..4;
+ my @users = treeget($znctree, "User", "Node");
+ foreach my $user (@users) {
+ if ($user eq $username) {
+ main::putserv($bot, "PRIVMSG $nick :Sorry, username taken. Please contact staff if you need help.");
+ }
+ }
+ #my $captcha = join'', map +(0..9,'a'..'z','A'..'Z')[rand(10+26*2)], 1..4;
my $captcha = int(rand(999));
my $ircid = int(rand(2147483647));
SQLite::set("irc", "id", $ircid, "localtime", time());
@@ -201,6 +261,40 @@ sub mforeach {
}
}
+sub mcontrolpanel {
+ my ($bot, $nick, $host, $hand, @args) = @_;
+ my ($chan, $text);
+ if (@args == 2) {
+ ($chan, $text) = ($args[0], $args[1]);
+ } else { $text = $args[0]; }
+ my $hostmask = "$nick!$host";
+ if($hostmask eq '*controlpanel!znc@znc.in') {
+ if ($text =~ /^Error: User \[cloneuser\] does not exist/) {
+ createclone($bot);
+ foreach my $chan (@teamchans) {
+ main::putserv($bot, "PRIVMSG $chan :Cloneuser created");
+ }
+ } elsif ($text =~ /^User (.*) added!$/) {
+ main::debug(ALL, "User $1 created");
+ } elsif ($text =~ /^Password has been changed!$/) {
+ main::debug(ALL, "Password changed");
+ } elsif ($text =~ /^Queued network (.*) of user (.*) for a reconnect.$/) {
+ main::debug(ALL, "$2 now connecting to $1...");
+ } elsif ($text =~ /^Admin = false/) {
+ foreach my $chan (@teamchans) {
+ main::putserv($bot, "PRIVMSG $chan :ERROR: $nick is not admin");
+ }
+ die "ERROR: $nick is not admin";
+ } elsif ($text =~ /^Admin = true/) {
+ main::debug(ALL, "$nick is ZNC admin");
+ } elsif ($text =~ /(.*) = (.*)/) {
+ my ($key, $val) = ($1, $2);
+ main::debug(ALL, "ZNC: $key => $val");
+ } else {
+ main::debug(ERRORS, "Unexpected: $hostmask $text");
+ }
+ }
+}
sub loadlog {
open(my $fh, '<', "$znclog") or die "Could not read file 'znc.log' $!";
chomp(@logs = <$fh>);
@@ -336,72 +430,6 @@ EOF
Mail::mail($mailfrom, $email, $mailname, "Verify IRCNow Account", $body);
}
-
-#if ($hostmask eq '*status!znc@znc.in' && $target =~ /^$nick.?$/) {
-# if ($reply eq "You are currently disconnected from IRC. Use 'connect' to reconnect.") {
-# if ($verbose >= 3) { print "not connected to $bot->{name}\n"; }
-# return;
-# } elsif ($reply =~ /Unable to load module (.*): Module (.*) already loaded./) {
-# if ($verbose >= 3) { print "Module $1 already loaded\n"; }
-# return;
-# } else {
-# print "Unexpected: $hostmask $target $reply\r\n";
-# }
-#} elsif($hostmask eq '*controlpanel!znc@znc.in') {
-# if ($reply =~ /^Error: User \[cloneuser\] does not exist/) {
-# createclone($bot);
-# sendteam($sender, "Cloneuser created!");
-# } elsif($reply =~ /^Nick = ([a-zA-Z][-_a-zA-Z0-9]+)$/) {
-## only one requestnick
-# my $requestnick = $1;
-# my $hostmask = firstval("requestnick", $requestnick);
-# if (!defined($hostmask)) { return; }
-# delkey($hostmask, "requestnick");
-# sendmsg($bot, nickfromhost($hostmask), "Username already taken. New username:");
-# } elsif($reply =~ /^Error: User \[(.*)\] does not exist/) {
-## delete requestnick after granted
-# my $newnick = $1;
-# my $hostmask = firstval("requestnick", $newnick);
-# if (!defined($hostmask)) { return; }
-# setkeyval($hostmask, "newnick", $newnick);
-# delkey($hostmask, "requestnick");
-# sendmsg($bot, nickfromhost($hostmask), "Email:");
-# } elsif ($reply =~ /^User (.*) added!$/) {
-# print "User $1 created!\r\n";
-# } elsif ($reply =~ /^Password has been changed!$/) {
-# print "Password changed\r\n";
-# } elsif ($reply =~ /^Queued network (.*) of user (.*) for a reconnect.$/) {
-# print "$2 now connecting to $1...\r\n";
-# } elsif ($reply =~ /^Admin = false/) {
-# sendteam("", "ERROR: $nick is not admin");
-# die "ERROR: $nick is not admin";
-# } elsif ($reply =~ /^Admin = true/) {
-# if ($verbose >= 3) { print "$nick is ZNC admin\n"; }
-# } elsif ($reply =~ /(.*) = (.*)/) {
-# my ($key, $val) = ($1, $2);
-# if ($verbose >= 3) { print "$key = $val\r\n"; }
-# } else {
-#print "Unexpected: $hostmask $target $reply\r\n";
-#}
-# if ($chans =~ $target) {
-# sendmsg($bot, $target, "$sender: Please check private message");
-# }
-# sendmsg($bot, $sender, $terms);
-# sendteam($bot->{name}, "Help *$sender* on ".$bot->{name});
-# }
-# } elsif(!defined(getkeyval($hostmask, "newnick"))) {
-# if ($reply =~ /^([a-zA-Z][-a-zA-Z0-9]+)/) {
-# setkeyval($hostmask, "requestnick", $reply);
-# sendmsg($bot, "*controlpanel", "get Nick $reply");
-# www($newnick, $reply, $password, "bouncer");
- # } elsif ($reply =~ /^!rehash$/i) {
- # if ($main::conf{staff} !~ /$sender/) {
- # return;
- # }
- # print $socket "PRIVMSG *controlpanel :deluser cloneuser\r\n";
- # sleep 5;
- # print $socket "PRIVMSG *controlpanel :get Nick cloneuser\r\n";
-
#sub resend {
# my ($bot, $newnick, $email) = @_;
# my $password = newpass();
@@ -416,8 +444,6 @@ EOF
# resend($bot, $newnick, $email);
# }
-
-
#sub resetznc {
#
#AnonIPLimit 10000
@@ -445,5 +471,4 @@ EOF
#webadmin Web based administration module.
-#main::putserv($bot, "PRIVMSG $teamchan :nick: $nick, host: $host, hand: $hand, chan: $chan, text: $text");
1; # MUST BE LAST STATEMENT IN FILE
blob - 3149b97ef215e865770db53d14a81cd9a7c8d3f0
blob + e660d9b341956b454835944c333fd87d803893d6
--- Commands
+++ Commands
@@ -8,32 +8,32 @@ Sends text to the IRC server. Returns nothing.
Bind
========
-bind BOT TYPE FLAGS MASK PROC
+bind TYPE FLAGS MASK PROC
Binds perl procedures to events. Currently flags and mask are ignored. Returns the name of the command that was added.
1. MSG
-bind BOT "MSG" FLAGS COMMAND PROC
-procname NICK USERHOST HANDLE TEXT
+bind "MSG" FLAGS COMMAND PROC
+procname BOT NICK USERHOST HANDLE TEXT
Called on /msg commands. The first word of the msg is the command, and the rest
the text.
-bind($bot, "msg", "", "admin", $proc);
+bind("msg", "", "admin", $proc);
sub proc {
- my ($nick, $userhost, $hand, $text) = @_;
+ my ($bot, $nick, $userhost, $hand, $text) = @_;
...
}
2. PUB
-bind BOT "PUB" FLAGS COMMAND PROC
-procname NICK USERHOST HANDLE CHANNEL TEXT
+bind "PUB" FLAGS COMMAND PROC
+procname BOT NICK USERHOST HANDLE CHANNEL TEXT
-bind($bot, "pub", "", "help", $proc);
+bind("pub", "", "help", $proc);
sub proc {
- my ($nick, $userhost, $hand, $chan, $text) = @_;
+ my ($bot, $nick, $userhost, $hand, $chan, $text) = @_;
...
}
@@ -42,12 +42,12 @@ the text.
3. MSGM (stackable)
-bind BOT "MSGM" FLAGS MASK PROC
-procname NICK USERHOST HANDLE TEXT
+bind "MSGM" FLAGS MASK PROC
+procname BOT NICK USERHOST HANDLE TEXT
-bind($bot, "msgm", "", "", $proc);
+bind("msgm", "", "", $proc);
sub proc {
- my ($nick, $userhost, $hand, $text) = @_;
+ my ($bot, $nick, $userhost, $hand, $text) = @_;
...
}
@@ -55,12 +55,12 @@ Match all text from a /msg. MSGM binds are processed b
4. PUBM (stackable)
-bind BOT "PUBM" FLAGS MASK PROC
-procname NICK USERHOST HANDLE CHAN TEXT
+bind "PUBM" FLAGS MASK PROC
+procname BOT NICK USERHOST HANDLE CHAN TEXT
-bind($bot, "pubm", "", "", $proc);
+bind("pubm", "", "", $proc);
sub proc {
- my ($nick, $userhost, $hand, $chan, $text) = @_;
+ my ($bot, $nick, $userhost, $hand, $chan, $text) = @_;
...
}
@@ -68,12 +68,12 @@ Match all text from a message on a channel. PUBM binds
5. NOTC (stackable)
-bind BOT "NOTC" FLAGS MASK PROC
-procname NICK USERHOST HANDLE TEXT DEST
+bind "NOTC" FLAGS MASK PROC
+procname BOT NICK USERHOST HANDLE TEXT DEST
-bind($bot, "notc", "", "", $proc);
+bind("notc", "", "", $proc);
sub proc {
- my ($nick, $userhost, $hand, $text, $dest) = @_;
+ my ($bot, $nick, $userhost, $hand, $text, $dest) = @_;
...
}
@@ -82,12 +82,12 @@ You should not respond to a /notice, so this is useful
6. JOIN (stackable)
-bind BOT "JOIN" FLAGS MASK PROC
-procname NICK USERHOST HANDLE CHANNEL
+bind "JOIN" FLAGS MASK PROC
+procname BOT NICK USERHOST HANDLE CHANNEL
-bind($bot, "join", "", "", $proc);
+bind("join", "", "", $proc);
sub proc {
- my ($nick, $userhost, $hand, $chan) = @_;
+ my ($bot, $nick, $userhost, $hand, $chan) = @_;
...
}
@@ -95,12 +95,12 @@ Called when someone joins a channel.
7. PART (stackable)
-bind BOT "PART" FLAGS MASK PROC
-procname NICK USERHOST HANDLE CHANNEL TEXT
+bind "PART" FLAGS MASK PROC
+procname BOT NICK USERHOST HANDLE CHANNEL TEXT
-bind($bot, "part", "", "", $proc);
+bind("part", "", "", $proc);
sub proc {
- my ($nick, $userhost, $hand, $chan, $text) = @_;
+ my ($bot, $nick, $userhost, $hand, $chan, $text) = @_;
...
}
blob - 755e54ea545a77548d896281f26e15cbce9d3acb
blob + 83071b696ac9d6bb680ab6a789660767ef5f7d69
--- DNS.pm
+++ DNS.pm
@@ -6,30 +6,34 @@ use strict;
use warnings;
use OpenBSD::Pledge;
use OpenBSD::Unveil;
+use Data::Dumper;
use File::Copy qw(copy);
-my $staff;
+my %conf;
my $chans;
+my $staff;
my $key;
my $hash;
-my $zonedir = '/var/nsd/zones/master/';
my $hostname;
my $verbose;
my $ipv4;
-my @ipv6s;
+my $zonedir;
my $ipv6path;
my $hostnameif;
+my @ipv6s;
sub init {
- $chans = $main::conf{chans};
- $staff = $main::conf{staff};
- $key = $main::conf{key};
- $hash = $main::conf{hash};
- $hostname = $main::conf{hostname};
- $verbose = $main::conf{verbose};
- $ipv4 = $main::conf{ipv4};
- $ipv6path = "ipv6s";
- $hostnameif = $main::conf{hostnameif};
+ %conf = %main::conf;
+ $chans = $conf{chans};
+ $staff = $conf{staff};
+ $key = $conf{key};
+ $hash = $conf{hash};
+ $hostname = $conf{hostname};
+ $verbose = $conf{verbose};
+ $ipv4 = $conf{ipv4};
+ $zonedir = $conf{zonedir};
+ $ipv6path = $conf{ipv6path};
+ $hostnameif = $conf{hostnameif};
unveil("$ipv6path", "rwc") or die "Unable to unveil $!";
unveil("$zonedir", "rwc") or die "Unable to unveil $!";
#dependencies for doas
blob - /dev/null
blob + 2e744ee9dd4100c7d4b9a996075c6d131c759add (mode 644)
--- /dev/null
+++ Help.pm
@@ -0,0 +1,62 @@
+#!/usr/bin/perl
+
+package Help;
+
+use strict;
+use warnings;
+use OpenBSD::Pledge;
+use OpenBSD::Unveil;
+
+my $chans;
+my $teamchans;
+my @teamchans;
+my $staff;
+my $terms;
+my $time = "600";
+
+sub init {
+ $chans = $main::conf{chans};
+ $teamchans = $main::conf{teamchans};
+ @teamchans = split /[,\s]+/m, $teamchans;
+ $staff = $main::conf{staff};
+ $terms = $main::conf{terms};
+ main::cbind("pub", "-", "help", \&help);
+ main::cbind("msg", "-", "help", \&help);
+ main::cbind("pub", "-", "request", \&help);
+}
+
+sub help {
+ my ($bot, $nick, $host, $hand, @args) = @_;
+ my ($chan, $text);
+ my $msg = <<"EOF";
+$terms
+To request a free bouncer, type !bnc <username> <email>. For example, !bnc john john\@example.com.
+To request a free shell account, type !shell <username> <email>. For example, !shell john john\@example.com.
+EOF
+#To request a free email account, type !email <username> <email>. For example, !email john john\@example.com.
+#To request a free VPN account, type !vpn <username> <email>. For example, !vpn john john\@example.com.
+ if ($staff =~ /$nick/) {
+ $msg .= <<"EOF";
+To delete a bouncer, type !bnc delete <username>
+To verify a captcha, type !bnc captcha <username>
+To recreate cloneuser, type !bnc cloneuser
+To get a list of usernames that match IPs, type !regex ips <ips>
+To get a list of IPs that match usernames, type !regex users <usernames>
+To regex search znc.log and output to the terminal, type !regex <regex>
+EOF
+ }
+ if (@args == 2) {
+ ($chan, $text) = ($args[0], $args[1]);
+ if ($chans =~ $chan) {
+ main::putserv($bot, "PRIVMSG $chan :$nick: Please see private message.");
+ }
+ } else {
+ $text = $args[0];
+ }
+ main::putserv($bot, "PRIVMSG $nick :$msg");
+ foreach my $chan (@teamchans) {
+ main::putserv($bot, "PRIVMSG $chan :Help *$nick* on ".$bot->{name});
+ }
+}
+
+1; # MUST BE LAST STATEMENT IN FILE
blob - c083ae01cf9be4d0183eb27f62ba95909ed8f398 (mode 644)
blob + /dev/null
--- botnow.conf.full
+++ /dev/null
@@ -1,56 +0,0 @@
-# Name of local network; default ircnow
-# localnet = ircnow
-
-# Internal IPv4 address and plaintext port; default 127.0.0.1@1337
-# host = 127.0.0.1
-# port = 1337
-
-# Bouncer hostname; default uses return of `hostname`
-# hostname = example.ircnow.org
-
-# External IPv4 address, plaintext and ssl port
-# ip4 = 192.168.0.1
-# plainport = 1337
-# sslport = 31337
-
-# Nick and password of bot -- make sure to add to oper block
-nick = botnow
-pass = password
-
-# Comma-separated list of channels for requesting bouncers
-# chans = #ircnow,#testing
-
-# Number of words in password
-# passlength = 3
-
-# Comma-separated list of staff nicks; comment out to avoid highlights
-staff = jrmu,test
-
-# Comma-separated list of team channels on localnet; comment out to disable
-# teamchans = #ircnow-team
-
-# Mail from address
-mailfrom = support@ircnow.org
-# mailname = support
-
-# DNS zone directory
-# zonedir = /var/nsd/zones/master/
-
-# rDNS keys from Stallion in BuyVM
-key = ABCDE-FGHIJ-KLMNO
-hash = ABCDEFGHIJKLMNOPQRST
-
-# ZNC install directory
-# zncdir = /home/znc/home/znc/
-
-# Network Interface Config File
-# hostnameif = /etc/hostname.vio0
-
-# Verbosity: 0 (no errors), 1 (errors), 2 (warnings), 3 (diagnostic)
-# verbose = 0
-
-# Terms of Service
-# terms = IRCNow is a Christian network. Rules: no profanity, no porn, no illegal drugs, no gambling, no slander, no warez, no promoting violence, no spam, illegal cracking, or DDoS. Only one account per person. Don't share passwords. Religious or political content may be moderated. Full terms: https://ircnow.org/terms.php . Do you agree? (yes/no)
-
-# Comment out the line below
-die = You did not configure botnow.conf!
blob - 79c3525909504abecf65b117c26098c3d0177a2f (mode 644)
blob + /dev/null
--- botnow.conf.sample
+++ /dev/null
@@ -1,41 +0,0 @@
-# For all options, see botnow.conf.full
-# Name of local network; default ircnow
-#localnet = ircnow
-
-# Internal IPv4 address and plaintext port; default 127.0.0.1@1337
-#host = 127.0.0.1
-#port = 1337
-
-# Bouncer hostname; default uses return of `hostname`
-#hostname = example.ircnow.org
-
-# External IPv4 address, plaintext and ssl port
-#ip4 = 192.168.0.1
-#plainport = 1337
-#sslport = 31337
-
-# Nick and password of bot -- make sure to add to oper block
-nick = botnow
-pass = password
-
-# List of channels for requesting bouncers
-chans = #ircnow #testing
-
-# List of staff nicks; comment out to avoid highlights
-staff = jrmu test
-
-# List of team channels on localnet; comment out to disable
-teamchans = #ircnow-team
-
-# Mail from address
-mailfrom = support@ircnow.org
-
-# rDNS keys from Stallion in BuyVM
-key = ABCDE-FGHIJ-KLMNO
-hash = ABCDEFGHIJKLMNOPQRST
-
-# ZNC install directory
-#zncdir = /home/znc/home/znc/
-
-# Comment out the line below
-die = You did not configure botnow.conf!
blob - /dev/null
blob + 4b3b776731229d5fd55f6884b1a4c8b6604295ee (mode 644)
--- /dev/null
+++ botnow.conf.example
@@ -0,0 +1,76 @@
+#Name of local network; default ircnow
+#localnet = ircnow
+
+#Internal IPv4 address and plaintext port; default 127.0.0.1@1337
+#host = 127.0.0.1
+#port = 1337
+
+#Bouncer hostname; default uses return of `hostname`
+#hostname = example.ircnow.org
+
+#External IPv4 address, plaintext and ssl port
+#ip4 = 192.168.0.1
+#plainport = 1337
+#sslport = 31337
+
+#Nick and password of bot -- make sure to add to oper block
+nick = botnow
+pass = password
+
+#List of channels for requesting bouncers
+chans = #ircnow #testing
+
+#List of staff nicks; comment out to avoid highlights
+staff = jrmu test
+
+#List of team channels on localnet; comment out to disable
+teamchans = #ircnow-team
+
+#Mail from address
+mailfrom = support@ircnow.org
+#mailname = support
+
+#rDNS keys from Stallion in BuyVM
+key = ABCDE-FGHIJ-KLMNO
+hash = ABCDEFGHIJKLMNOPQRST
+
+#Comment out the line below
+die = You did not configure botnow.conf!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#Advanced Options
+
+#Number of words in password
+#passlength = 3
+
+#DNS zone directory
+#zonedir = /var/nsd/zones/master/
+
+#ZNC install directory
+#zncdir = /home/znc/home/znc/
+
+#Network Interface Config File
+#hostnameif = /etc/hostname.vio0
+
+#Verbosity: NONE, ERRORS, WARNINGS, ALL
+#verbose = ERRORS
+
+#Terms of Service
+#terms = IRCNow is a Christian network. Rules: no profanity, no porn, no illegal drugs, no gambling, no slander, no warez, no promoting violence, no spam, illegal cracking, or DDoS. Only one account per person. Don't share passwords. Full terms: https://ircnow.org/terms.php .
blob - ce69c1f51909bc29e8f5be3221e293785e7af821
blob + 71e0910afd05778613469df8579c0f0336815f06
--- botnow.pl
+++ botnow.pl
@@ -14,6 +14,7 @@ use Shell;
use SQLite;
use WWW;
use Hash;
+use Help;
my $confpath = "botnow.conf";
our %conf;
@@ -68,6 +69,9 @@ $conf{hash} = $conf{hash} or die "ERROR: botnow.conf:
# ZNC install directory
$conf{zncdir} = $conf{zncdir} || "/home/znc/home/znc";
+# NSD zone dir
+$conf{zonedir} = $conf{zonedir} || "/var/nsd/zones/master/";
+
# Network Interface Config File
$conf{hostnameif} = $conf{hostnameif} || "/etc/hostname.vio0";
@@ -81,7 +85,7 @@ use constant {
$conf{verbose} = $conf{verbose} || ERRORS;
# Terms of Service; don't edit lines with the word EOF
-$conf{terms} = $conf{terms} || "IRCNow is a Christian network. Rules: no profanity, no porn, no illegal drugs, no gambling, no slander, no warez, no promoting violence, no spam, illegal cracking, or DDoS. Only one account per person. Don't share passwords. Full terms: https://ircnow.org/terms.php";
+$conf{terms} = $conf{terms} || "IRCNow: Of the User, By the User, For the User. Rules: no profanity, no porn, no illegal drugs, no gambling, no slander, no warez, no promoting violence, no spam, illegal cracking, or DDoS. Only one account per person. Don't share passwords. Full terms: https://ircnow.org/terms.php";
$conf{ipv6path} = "ipv6s"; # ipv6 file path
$conf{netpath} = "networks"; # networks file path
@@ -90,7 +94,6 @@ $conf{time} = 600; # time difference
if(defined($conf{die})) { die $conf{die}; }
# Initiate modules
-
BNC::init();
DNS::init();
SQLite::init();
@@ -98,6 +101,7 @@ Mail::init();
Shell::init();
WWW::init();
Hash::init();
+Help::init();
our @networks;
my @bots;
@@ -247,8 +251,16 @@ while(my @ready = $sel->can_read) {
}
} elsif($response =~ /^:(([^!]+)!([^@]+@[^@ ]+)) PRIVMSG ([^ ]+) :(.*)\r\n$/i) {
my ($hostmask, $nick, $host, $target, $text) = ($1, $2, $3, $4, $5);
- if ($hostmask eq '*status!znc@znc.in' && $target =~ /^$botnick.?$/ && $text =~ /Network ([[:ascii:]]+) doesn't exist./) {
- debug(ERRORS, "$1 is not connected");
+ if ($hostmask eq '*status!znc@znc.in' && $target =~ /^$botnick.?$/) {
+ if ($text =~ /Network ([[:ascii:]]+) doesn't exist./) {
+ debug(ERRORS, "$1 is not connected");
+ } elsif ($text eq "You are currently disconnected from IRC. Use 'connect' to reconnect.") {
+ debug(ERRORS, "not connected to $bot->{name}");
+ } elsif ($text =~ /Unable to load module (.*): Module (.*) already loaded./) {
+ debug(ALL, "Module $1 already loaded\n");
+ } else {
+ debug(ERRORS, "Unexpected: $hostmask $target");
+ }
} elsif ($text =~ /!([[:graph:]]+)\s*(.*)/) {
my ($cmd, $text) = ($1, $2);
my $hand = $staff; # TODO fix later
@@ -267,6 +279,20 @@ while(my @ready = $sel->can_read) {
}
}
}
+ } else {
+ my $hand = $staff; # TODO fix later
+ if ($target =~ /^#/) {
+ foreach my $c (@{$call->{pubm}}) {
+ my $proc = $c->{proc};
+ $proc->($bot, $nick, $host, $hand, $target, $text);
+ }
+ } else {
+ foreach my $c (@{$call->{msgm}}) {
+ my $proc = $c->{proc};
+ $proc->($bot, $nick, $host, $hand, $text);
+ print "$proc->($bot, $nick, $host, $hand, $text)\n";
+ }
+ }
}
debug(ALL, "$hostmask $target $text");
} elsif($response =~ /^:(([^!]+)!([^@]+@[^@ ]+)) NOTICE ([^ ]+) :(.*)\r\n$/i) {
@@ -503,6 +529,10 @@ sub cbind {
push(@{$call->{join}}, {mask => $cmd, proc => $proc});
} elsif ($type eq "partcall") {
push(@{$call->{part}}, {mask => $cmd, proc => $proc});
+ } elsif ($type eq "pubm") {
+ push(@{$call->{pubm}}, {mask => $cmd, proc => $proc});
+ } elsif ($type eq "msgm") {
+ push(@{$call->{msgm}}, {mask => $cmd, proc => $proc});
}
}
blob - a945ac4599891fe4484b5807cc5b0950839ba880
blob + e9868ea995dc6527834c9d0181f0de3d53f19e83
--- makefile
+++ makefile
@@ -22,7 +22,7 @@ botnow:
chmod ug+rw ${ZONES}/*
echo "permit nopass ${USERNAME} as _nsd cmd nsd-control" >> /etc/doas.conf
cp register.php ${HTDOCS}/
- cp LICENSE README botnow.pl botnow.conf.sample botnow.conf.full BNC.pm DNS.pm Mail.pm SQLite.pm Shell.pm VPN.pm Login.pm WWW.pm table.sql Hash.pm makefile networks register.php words shell ${HOMEDIR}/
+ cp LICENSE README botnow.pl botnow.conf.example BNC.pm DNS.pm Mail.pm SQLite.pm Shell.pm VPN.pm Login.pm WWW.pm table.sql Hash.pm Help.pm makefile networks register.php words shell ${HOMEDIR}/
chown -R ${USERNAME}:${USERNAME} ${HOMEDIR}
chmod u+x ${HOMEDIR}/botnow.pl
chown -R ${ZNCUSER}:daemon ${ZNCDIR}
blob - a8af2958b80a3ebf6c2a1666ea5788c2e29861ea
blob + 4972b4796b128ce465d7cb0029e8bb237ae94c48
--- networks
+++ networks
@@ -14,6 +14,8 @@ ircnow Your-IP-address 6667
2600net irc.2600.net 6667
42net sol.42net.org 6667
#abandoned-irc irc.abandoned-irc.net ~6697
+#abjects irc.abjects.net +6697
+absoluty irc.absoluty-irc.fr 6667
aerospacechat irc.aerospacechat.com +6697
afterall irc.after-all.org 6667
afternet irc.afternet.org +6697
@@ -26,9 +28,11 @@ alphachat irc.alphachat.net +6697
amicachat irc.amicachat.net ~6697
amorlatino irc.amorlatino.org 6667
anope irc.anope.org 6667
+austnet irc.austnet.org +6697
atrum irc.atrum.org ~6697
axon irc.axon.pw +6697
ayochat irc.ayochat.or.id 6667
+azzurra irc.azzurra.org +6697
banglacafe irc.banglacafe.com 6667
barton irc.barton.de 6667
bgirc irc.bgirc.com ~6697
@@ -48,6 +52,7 @@ chathub irc.chathub.org +6697
chating irc.chating.id 6667
chatlatino irc.chatlatinos.cl 9090
chatlounge irc.chatlounge.net +6697
+chatplezier irc.chatplezier.com ~6697
chatspike irc.chatspike.net ~6697
chatzona irc.chatzona.org 6667
#coolsmile irc.coolsmile.net +6697
@@ -112,10 +117,12 @@ evolu irc.evolu.net ~6697
exchat irc.exchat.net ~6697
explosionirc irc.explosionirc.net 6667
forumcerdas irc.forumcerdas.net ~6697
+frantech irc.frantech.ca +6697
freenode ipv6.chat.freenode.net +6697
#freenode chat.ipv6.freenode.net +6697
freeunibg irc.freeunibg.eu 6667
freshchat irc.freshchat.org +6697
+#furnet irc.furnet.org +6697
gamesurge irc.gamesurge.net 6667
geeknode irc.geeknode.org +6697
geekshed irc.geekshed.net +6697
@@ -126,6 +133,7 @@ gimp irc.gimp.org +6697
globalirc irc.global-irc.org 6667
globalirc-it irc.globalirc.it ~6697
greekirc irc.greekirc.net 6667
+hackint irc.hackint.org +6697
hybridirc irc.hybridirc.com ~6697
icqchat irc.icq-chat.com +6697
insomnia irc.insomnia247.nl 6667
@@ -144,13 +152,15 @@ ircnet irc.psychz.net ~6697
ircnet openirc.snt.utwente.nl 6667
ircnet irc.portlane.se ~6697
ircnet irc.nlnog.net 6667
+irctl chat.irc.tl ~6697
irczone irc6.irczone.net ~6697
italian-amici irc.italian-amici.org 6667
juggler irc.juggler.jp 6667
kalbim irc.kalbim.net 6667
-kampungchat ipv6.fat2fit.ch 6667
+kampungchat etnies6.ircd.link 6667
librairc irc.librairc.net ~6697
luatic irc.luatic.net 6667
+magnet irc.shadowcat.co.uk 6667
mibbit irc.mibbit.com ~6697
mindforge irc.mindforge.org 6667
myirc chat.myirc.net +6697
@@ -158,11 +168,11 @@ nationchat irc.nationchat.org 6667
netchat irc.netchat.cl 6667
oftc irc6.oftc.net +6697
#oftc irc.oftc.net +6697
-ogn irc.onlinegamesnet.net 6667
oltreirc irc.oltreirc.net +6697
onlinegamesnet irc.onlinegamesnet.net 6667
openjoke irc.openjoke.org ~6697
#optilan irc.optilan.eu 6667
+#p2p-net irc.p2p-network.net +6697
perl irc.perl.org 6667
pirc-pl irc.pirc.pl +6697
ptnet irc.ptnet.org +6697
@@ -218,8 +228,10 @@ rusnet irc.lucky.net 6660
#rusnet irc.tambov.ru 6660
#rusnet irc.meganet.ru 6660
#rusnet irc.odessa.ua 6660
+#scenep2p irc.scenep2p.net ~6697
shadowcat irc.shadowcat.co.uk 6667
simosnap irc.simosnap.com +6697
+skychatz irc.skychatz.org ~6697
slashnet irc.slashnet.org +6697
smurfnet irc.smurfnet.ch ~6697
snoonet irc.snoonet.org +6697