From 81e7a47aa9fbadf113f4f67eedd554665d06f316 Mon Sep 17 00:00:00 2001 From: Pasqualino Ferrentino Date: Fri, 19 Oct 2007 08:39:02 +0200 Subject: [PATCH] Added the keys for the mailer and the frequency --- src/etc/bcd_template.conf | 9 +++------ src/lib/Bcd.pm | 2 +- src/lib/Bcd/Bots/Manager.pm | 10 +++++----- src/lib/Bcd/Bots/NewAntNestsBot.pm | 16 +++++++--------- src/lib/Bcd/Bots/TrustBot.pm | 2 -- src/lib/Bcd/Common/Mail.pm | 6 +++--- src/lib/Bcd/Data/StatementsStash.pm | 2 +- 7 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/etc/bcd_template.conf b/src/etc/bcd_template.conf index 0cb3321..1a23d21 100644 --- a/src/etc/bcd_template.conf +++ b/src/etc/bcd_template.conf @@ -19,11 +19,8 @@ script 0 #for limitations in the Net::Server the directory cannot contain spaces. bcd_home -#this is the passphrase to unlock the secret key -#to sign the outgoing mails. +#this is the host which is acts as a smtp relay for the daemon +mailer -passphrase -#if the passphrase contains spaces, or if you want major security -#you can specify a file in which the passphrase is stored. -passphrase_file \ No newline at end of file +new_ant_nest_bot_frequency diff --git a/src/lib/Bcd.pm b/src/lib/Bcd.pm index 9b51e30..8800775 100644 --- a/src/lib/Bcd.pm +++ b/src/lib/Bcd.pm @@ -53,7 +53,7 @@ sub options { #I add some parameters - foreach(qw/test script help passphrase passphrase_file bcd_home/){ + foreach(qw/test script help bcd_home mailer new_ant_nest_bot_frequency/){ $template->{$_} = \$prop->{$_}; } } diff --git a/src/lib/Bcd/Bots/Manager.pm b/src/lib/Bcd/Bots/Manager.pm index 65e6e07..d67c8f0 100644 --- a/src/lib/Bcd/Bots/Manager.pm +++ b/src/lib/Bcd/Bots/Manager.pm @@ -45,11 +45,11 @@ sub run{ my @bots = (); - my $bot = Bcd::Bots::NewAntNestsBot->new(); + my $bot = Bcd::Bots::NewAntNestsBot->new($server); my $bot_info = { bot => $bot, - seconds_to_go => $bot->get_frequency($test), + seconds_to_go => $bot->get_frequency(), is_running => 0, }; @@ -59,7 +59,7 @@ sub run{ my $bot_info2 = { bot => $bot, - seconds_to_go => $bot->get_frequency($test), + seconds_to_go => $bot->get_frequency(), is_running => 0, }; @@ -81,7 +81,7 @@ sub run{ if ($cycle_finished == 1){ #ok, this bot has finished, wait for another epoch $_->{is_running} = 0; - $_->{seconds_to_go} = $_->{bot}->get_frequency($test); + $_->{seconds_to_go} = $_->{bot}->get_frequency(); } next; } @@ -97,7 +97,7 @@ sub run{ $_->{is_running} = 1; } else { #wait for another epoch - $_->{seconds_to_go} = $_->{bot}->get_frequency($test); + $_->{seconds_to_go} = $_->{bot}->get_frequency(); } } diff --git a/src/lib/Bcd/Bots/NewAntNestsBot.pm b/src/lib/Bcd/Bots/NewAntNestsBot.pm index fd1e140..d41da9d 100644 --- a/src/lib/Bcd/Bots/NewAntNestsBot.pm +++ b/src/lib/Bcd/Bots/NewAntNestsBot.pm @@ -41,7 +41,6 @@ Log::Log4perl->easy_init($DEBUG); use constant { MAXIMUM_TIME_TO_CHECK_IN => 86400, MY_FREQUENCY => 7200, - MY_TEST_FREQUENCY => 30, }; @@ -73,7 +72,7 @@ use constant { #" sub new { - my $class = shift; + my ($class, $server) = @_; my $self = $class->SUPER::new(@_); $self->_add_rule(\&delete_founders_ants_not_checked); @@ -85,18 +84,17 @@ sub new { $self->_add_rule(\&new_ant_nest_final_rule); + $self->{my_frequency} = defined($server->{new_ant_nest_bot_frequency}) ? + $server->{new_ant_nest_bot_frequency} : MY_FREQUENCY; + + bless($self, $class); return $self; } sub get_frequency { - my ($self, $test) = @_; - - if ($test == 0){ - return MY_FREQUENCY; - } else { - return MY_TEST_FREQUENCY; - } + my $self = shift; + return $self->{my_frequency}; } #I should start a new cycle. diff --git a/src/lib/Bcd/Bots/TrustBot.pm b/src/lib/Bcd/Bots/TrustBot.pm index 82a98e4..ee8f781 100644 --- a/src/lib/Bcd/Bots/TrustBot.pm +++ b/src/lib/Bcd/Bots/TrustBot.pm @@ -62,8 +62,6 @@ sub new { } sub get_frequency { - my ($self, $test) = @_; - return MY_FREQUENCY; } diff --git a/src/lib/Bcd/Common/Mail.pm b/src/lib/Bcd/Common/Mail.pm index 0a9137f..a311a40 100644 --- a/src/lib/Bcd/Common/Mail.pm +++ b/src/lib/Bcd/Common/Mail.pm @@ -36,14 +36,14 @@ use Bcd::Common::BcdGnuPGMail; use FindBin; sub new { - my $class = shift; + my ($class, $props) = @_; my $self = {}; #my $smtp = Net::SMTP->new('localhost', Hello => 'bricioline.it', Debug => 1); #$self->{smtp} = $smtp; $self->{is_testing} = 0; - + $self->{mailer} = $props->{mailer}; bless($self, $class); @@ -144,7 +144,7 @@ sub _get_safe_smtp_server{ my $self = shift; if (!defined($self->{smtp})){ - my $smtp = Net::SMTP->new('localhost', Hello => 'bricioline.it'); + my $smtp = Net::SMTP->new($self->{mailer}, Hello => 'bricioline.it'); $self->{smtp} = $smtp; } diff --git a/src/lib/Bcd/Data/StatementsStash.pm b/src/lib/Bcd/Data/StatementsStash.pm index 07603ed..c56841c 100644 --- a/src/lib/Bcd/Data/StatementsStash.pm +++ b/src/lib/Bcd/Data/StatementsStash.pm @@ -87,7 +87,7 @@ sub new { $self->{conn} = $conn; $self->{cache} = $cache; - $self->{mailer} = Bcd::Common::Mail->new(); + $self->{mailer} = Bcd::Common::Mail->new($server); $self->{testing}= 0; bless ($self, $class); -- 2.11.4.GIT