|
@@ -1,6 +1,7 @@
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
package Bot;
|
|
|
+use Mail::Sendmail;
|
|
|
use base qw(Bot::BasicBot);
|
|
|
use warnings;
|
|
|
use strict;
|
|
@@ -9,7 +10,7 @@ if(@ARGV && ! -w "$ARGV[0]" || !@ARGV) {
|
|
|
if(@ARGV) {
|
|
|
print "ERREUR: $ARGV[0] est inexistant ou non-inscriptible.\n";
|
|
|
} else {
|
|
|
- print "USAGE: ./$0 fichier-a-ecrire\n";
|
|
|
+ print "USAGE: $0 fichier-a-ecrire\n";
|
|
|
}
|
|
|
|
|
|
exit 1;
|
|
@@ -21,6 +22,12 @@ my $chan = "#fdn";
|
|
|
my $flag = "[ALERT]";
|
|
|
my $url = "http://fdn.ldn-fai.net";
|
|
|
my $git = "git clone http://repo.ldn-fai.net/repo/si-public.git";
|
|
|
+my $subscribe = "http://listes.ldn-fai.net/cgi-bin/mailman/listinfo/fdn";
|
|
|
+
|
|
|
+my $mail_support = 'support@fdn.fr';
|
|
|
+my $mail_liste = 'fdn@listes.ldn-fai.net';
|
|
|
+my $mail_from = 'fdnAlertBot <fdnAlertBot@ldn-fai.net>';
|
|
|
+my $mail_subject = "[ALERTE FDN] ";
|
|
|
|
|
|
my $isacc = 0;
|
|
|
my $file = $ARGV[0];
|
|
@@ -45,6 +52,9 @@ sub said {
|
|
|
} elsif($message->{"body"} =~ m/\b(?:git|svn|source)\b/i) {
|
|
|
$self->reply($message, $git);
|
|
|
|
|
|
+ } elsif($message->{"body"} =~ m/\bliste\b/i) {
|
|
|
+ $self->reply($message, "$mail_liste ($subscribe)");
|
|
|
+
|
|
|
} elsif($message->{"body"} =~ m/\bmerci\b/i) {
|
|
|
$self->reply($message, "De rien.");
|
|
|
|
|
@@ -61,29 +71,58 @@ sub topic {
|
|
|
my $self = shift;
|
|
|
my $args = shift;
|
|
|
|
|
|
+ my %mail = (
|
|
|
+ From => $mail_from,
|
|
|
+ To => $mail_liste,
|
|
|
+ Cc => $mail_support,
|
|
|
+ "Content-Type" => 'text/plain; charset="utf-8"'
|
|
|
+ );
|
|
|
+
|
|
|
if($args->{"topic"}) {
|
|
|
if($args->{"topic"} =~ /\Q$flag\E\s*(.+)$/i) {
|
|
|
- $isacc = 1;
|
|
|
+
|
|
|
+ $mail{"Message"} = $1;
|
|
|
|
|
|
open(OUT, ">$file");
|
|
|
print OUT "$1";
|
|
|
close(OUT);
|
|
|
|
|
|
- $bot->emote(
|
|
|
- channel => $chan,
|
|
|
- body => "a bien reporté le problème sur $url"
|
|
|
- );
|
|
|
+ if($isacc) {
|
|
|
+ $mail{"Subject"} = "$mail_subject Mise à jour de l'intitulé du problème";
|
|
|
+
|
|
|
+ $bot->emote(
|
|
|
+ channel => $chan,
|
|
|
+ body => "a bien actualisé le problème sur $url (et prévenu le support + $mail_liste)"
|
|
|
+ );
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $isacc = 1;
|
|
|
+ $mail{"Subject"} = "$mail_subject Nouveau problème déclaré";
|
|
|
+
|
|
|
+ $bot->emote(
|
|
|
+ channel => $chan,
|
|
|
+ body => "a bien reporté le problème sur $url (et prévenu le support + $mail_liste)"
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ sendmail(%mail) or die $Mail::Sendmail::error;
|
|
|
+
|
|
|
} elsif($isacc) {
|
|
|
$isacc = 0;
|
|
|
|
|
|
+ $mail{"Subject"} = "$mail_subject Problème résolu";
|
|
|
+ $mail{"Message"} = "Fin de l'alerte.";
|
|
|
+
|
|
|
open(OUT, ">$file");
|
|
|
print OUT "";
|
|
|
close(OUT);
|
|
|
|
|
|
$bot->emote(
|
|
|
channel => $chan,
|
|
|
- body => "a bien pris en compte la fin du problème ($url)"
|
|
|
+ body => "a bien pris en compte la fin du problème sur $url (et prévenu le support + $mail_liste)"
|
|
|
);
|
|
|
+
|
|
|
+ sendmail(%mail) or die $Mail::Sendmail::error;
|
|
|
}
|
|
|
}
|
|
|
}
|