Commit Diff


commit - 0ae44377fd82cf39b704f260ce33e4358bf816cb
commit + 61ce1ed72cf555746707285b4bf4e96dff8cc5ad
blob - 3fbd20a8d09035d8cdf8d805e184dbb5f16123e2
blob + b003269f9560489f4aab54fd5c2f086e41df081e
--- botnow
+++ botnow
@@ -8,89 +8,12 @@ use IO::Select;
 use OpenBSD::Pledge;
 use OpenBSD::Unveil;
 use lib "./lib";
-use IRCNOW::IO qw(readarray); # for readarray
+use IRCNOW::IO qw(readarray :DEBUG :DateTime ); # for readarray
 
-#IB Moved to IRCNOW::IO.pm
-#IB
-#IBuse File::Copy qw(copy);
-#IBuse File::Basename;
-
 # Path to configuration file
 my $confpath = "botnow.conf";
 my $backupspath = "/home/botnow/backups/";
 
-# Returns date in YYYYMMDD format
-sub date {
-	my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
-	my $localtime = sprintf("%04d%02d%02d", $year+1900, $mon+1, $mday);
-	return $localtime;
-}
-
-#IB Moved to IRCNOW::IO.pm
-#IB
-#IB# Read from filename and return array of lines without trailing newlines
-#IBsub readarray {
-#IB	my ($filename) = @_;
-#IB	open(my $fh, '<', $filename) or die "Could not read file '$filename' $!";
-#IB	chomp(my @lines = <$fh>);
-#IB	close $fh;
-#IB	return @lines;
-#IB}
-#IB
-#IB# Read from filename and return as string
-#IBsub readstr {
-#IB	my ($filename) = @_;
-#IB	open(my $fh, '<', $filename) or die "Could not read file '$filename' $!";
-#IB	my $str = do { local $/; <$fh> };
-#IB	close $fh;
-#IB	return $str;
-#IB}
-#IB
-#IB# Write str to filename
-#IBsub writefile {
-#IB	my ($filename, $str) = @_;
-#IB	my $date = date();
-#IB	copy($filename, $backupspath.basename($filename).".".date()) or die "Could not make backup of $filename";
-#IB	open(my $fh, '>', "$filename") or die "Could not write to $filename";
-#IB	print $fh $str;
-#IB	close $fh;
-#IB}
-#IB
-#IB# Append str to filename
-#IBsub appendfile {
-#IB	my ($filename, $str) = @_;
-#IB	open(my $fh, '>>', "$filename") or die "Could not append to $filename";
-#IB	print $fh $str;
-#IB	close $fh;
-#IB}
-
-# Returns timestamp in "Day MM DD HH:MM:SS" format
-sub gettime {
-	my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
-	my @days = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
-	my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
-	my $localtime = sprintf("%s %s %d %02d:%02d:%02d", $days[$wday], $months[$mon], $mday, $hour, $min, $sec);
-	return $localtime;
-}
-
-sub mail {
-	my( $from, $to, $fromname, $subject, $body )=@_;
-my $msg = <<"EOF";
-From: $from
-To: $to
-Subject: $subject
-MIME-Version: 1.0 
-Content-Type: text/plain; charset=us-ascii
-Content-Disposition: inline
-
-$body
-EOF
-open(my $fh, "| /usr/sbin/sendmail -tv -F '$fromname' -f $from") or die "Could not send mail $!";
-print $fh $msg;
-close $fh;
-return "true";
-}
-
 # Configuration variables will be stored in key => value pairs
 our %conf;
 
@@ -170,13 +93,6 @@ $conf{zncdir} = $conf{zncdir} || "/home/znc/home/znc";
 # Network Interface Config File
 $conf{hostnameif} = $conf{hostnameif} || "/etc/hostname.vio0";
 
-# Verbosity: 0 (no errors), 1 (errors), 2 (warnings), 3 (diagnostic)
-use constant {
-	NONE => 0,
-	ERRORS => 1,
-	WARNINGS => 2,
-	ALL => 3,
-};
 $conf{verbose} = $conf{verbose} || ERRORS;
 
 if(defined($conf{die})) { die $conf{die}; }
@@ -580,11 +496,6 @@ sub cbind {
 	}
 }
 
-sub debug {
-	my ($level, $msg) = @_;
-	if ($verbose >= $level) { print "$msg\n"; }
-}
-
 sub isstaff {
 	my( $bot, $nick ) = @_;
 	if( !( $bot->{name} =~ /^$localnet$/i ) ) {
blob - 8a7da72f675a0775f8c52dcca9969e79ed8acd14
blob + d2a2613d900ec4ee452442077287565aa6f19773
--- lib/BotNow/BNC.pm
+++ lib/BotNow/BNC.pm
@@ -5,6 +5,7 @@ use warnings;
 use OpenBSD::Pledge;
 use OpenBSD::Unveil;
 use Digest::SHA qw(sha256_hex);
+use lib qw(./lib);
 use IRCNOW::IO qw(readarray);
 require "BotNow::SQLite";
 require "BotNow::Hash";
blob - 7e28005a91c166f812f1818c857ae767f2c66fad
blob + 3d12bc62f3204cd3ebdc1628e046e137226e8966
--- lib/BotNow/DNS.pm
+++ lib/BotNow/DNS.pm
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use OpenBSD::Pledge;
 use OpenBSD::Unveil;
+use lib qw(./lib);
 use IRCNOW::IO qw(readarray writefile appendfile);
 
 use File::Copy qw(copy);
blob - 1913e71391f900d8a17b6c41ce935e611ffd3788
blob + e93919b95f4178042a5054bb2da30412e26ac129
--- lib/BotNow/Hash.pm
+++ lib/BotNow/Hash.pm
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use OpenBSD::Pledge;
 use OpenBSD::Unveil;
-
+use lib qw(./lib);
 use IRCNOW::IO qw(readarray);
 
 
blob - 59651cb328848b241afbe8a637f036f3c6d33fdb
blob + 48e016f8a436f386d522aaa725c3ff7e62dca254
--- lib/BotNow/Mail.pm
+++ lib/BotNow/Mail.pm
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use OpenBSD::Pledge;
 use OpenBSD::Unveil;
+use lib qw(./lib);
 use IRCNOW::IO qw(readarray writefile);
 
 use File::Copy qw(copy);
blob - fc0aa6d5d798e4699f4f906915680c92c623ffc0
blob + 9b9558224d98a5b8ea25c5a25027ac4a584b1e09
--- lib/BotNow/SQLite.pm
+++ lib/BotNow/SQLite.pm
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use OpenBSD::Pledge;
 use OpenBSD::Unveil;
+use lib qw(./lib);
 use IRCNOW::IO qw(readstr);
 
 use Data::Dumper;
blob - 89604e329d188258a594ea093765ed66fd511319
blob + 803e30c732c0446fce3b6e12349424af16d133fa
--- lib/BotNow/Sh.pm
+++ lib/BotNow/Sh.pm
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use OpenBSD::Pledge;
 use OpenBSD::Unveil;
+use lib qw(./lib);
 use IRCNOW::IO qw(readarray);
 
 use Data::Dumper;
blob - fa3ded11c573788eb65c0f9795e542bdae3d6399
blob + 7cacaa710c615561b54c005d1cc5e5e0f5a88f26
--- lib/BotNow/Shell.pm
+++ lib/BotNow/Shell.pm
@@ -4,13 +4,16 @@ use strict;
 use warnings;
 use OpenBSD::Pledge;
 use OpenBSD::Unveil;
-use IRCNOW::IO qw(:FILEIO);
+
 use MIME::Base64;
-use Data::Dumper;
 use Digest::SHA qw(sha256_hex);
-use lib './';
+
+use lib './lib';
+use IRCNOW::IO qw(:FILEIO);
 require "BotNow::SQLite";
 require "BotNow::Hash";
+
+use Data::Dumper;
 
 my %conf = %main::conf;
 my $chans = $conf{chans};