Commit Diff


commit - 857e8780e0133566f375c18fe274c410ee1d9967
commit + 32d1199ddfacc2acda862cd1ad7032be610f2d37
blob - 4e398b8cfdd56171f14756b42a7dbf0872ffd5fc
blob + bc434819232f19ca5d0cc7d99151faf0dbfa103e
--- mata_bot.pl
+++ mata_bot.pl
@@ -342,42 +342,41 @@ sub usage {
 }
 
 sub init {
-	my ($chan, $host, $path_ball, $path_helo, $path_quot, $port, $tls);
+	my ($path_ball, $path_helo, $path_quot);
+	my %opts;
 
 	@_ = @ARGV;
 	while (@_) {
 		$_ = shift;
 		if (/^-d$/) { logger(LOG_DEBUG) }
-		elsif (/^-t$/) { $tls = 1 }
+		elsif (/^-t$/) { $opts{'tls'} = 1 }
 		elsif (/^-v$/) { logger(LOG_WARN) }
 		elsif (@_ < 1) { usage() }
 		elsif (/^-b$/) { $path_ball = shift }
 		elsif (/^-e$/) { $path_helo = shift }
-		elsif (/^-h$/) { $host = shift }
-		elsif (/^-j$/) { $chan = '#' . shift }
-		elsif (/^-p$/) { $port = shift }
+		elsif (/^-h$/) { $opts{'host'} = shift }
+		elsif (/^-j$/) { $opts{'chan'} = '#' . shift }
+		elsif (/^-p$/) { $opts{'port'} = shift }
 		elsif (/^-q$/) { $path_quot = shift }
 		else { usage() }
 	}
-	open(my $ball_file, '<', $path_ball || $DEFAULT_PATH_BALL)
+	$opts{'chan'} //= $DEFAULT_CHAN;
+	$opts{'host'} //= $DEFAULT_HOST;
+	$opts{'port'} //= DEFAULT_PORT;
+	$opts{'tls'} //= DEFAULT_TLS;
+	open(my $ball_file, '<', $path_ball // $DEFAULT_PATH_BALL)
 		or die "couldn't open ${path_ball}: $!";
 	chomp(my @ball = <$ball_file>);
 	close $ball_file or die "${ball_file}: $!";
-	open(my $helo_file, '<', $path_helo || $DEFAULT_PATH_HELO)
+	open(my $helo_file, '<', $path_helo // $DEFAULT_PATH_HELO)
 		or die "couldn't open ${path_helo}: $!";
 	chomp(my @helo = <$helo_file>);
 	close $helo_file or die "${helo_file}: $!";
-	open(my $quot_file, '<', $path_quot || $DEFAULT_PATH_QUOT)
+	open(my $quot_file, '<', $path_quot // $DEFAULT_PATH_QUOT)
 		or die "couldn't open ${path_quot}: $!";
 	chomp(my @quot = <$quot_file>);
 	close $quot_file or die "${quot_file}: $!";
-	return {
-		chan => $chan || $DEFAULT_CHAN,
-		host => $host || $DEFAULT_HOST,
-		port => $port || DEFAULT_PORT,
-		tls => $tls || DEFAULT_TLS,
-	},
-	[
+	return \%opts, [
 		\@ball,
 		\@helo,
 		\@quot,