|
@@ -0,0 +1,342 @@
|
|
|
+#!/usr/bin/perl
|
|
|
+use warnings;
|
|
|
+use strict;
|
|
|
+
|
|
|
+package MyBot;
|
|
|
+use base qw( Bot::BasicBot );
|
|
|
+
|
|
|
+
|
|
|
+binmode STDOUT, ":utf8";
|
|
|
+use utf8;
|
|
|
+
|
|
|
+my $nb_adh = 0; # nombre d'adhérents
|
|
|
+my $nb_abo = 0; # nombre d'abonnés
|
|
|
+my $site = ""; # site web
|
|
|
+my $salon = ""; # salon irc/xmpp
|
|
|
+my $statut = 0; # étape de 1 à 8 du FAI
|
|
|
+my $date_crea = ""; # date de la création de l'asso
|
|
|
+my $date_jffdn = ""; # date de la rentrée dans la fédé
|
|
|
+my $contact = ""; # email de contact
|
|
|
+my $description = ""; # description de l'asso
|
|
|
+
|
|
|
+my $wrk_dir = "wrk-dir";
|
|
|
+
|
|
|
+# Lis le fichier contenant les infos d'un FAI
|
|
|
+sub info {
|
|
|
+ my $fai = shift @_;
|
|
|
+ my $filename = "/home/canouan/bot-irc/". $wrk_dir."/". $fai.".info";
|
|
|
+ my $fh;
|
|
|
+ open ($fh, '<', $filename) or die "Impossible d'ouvrir le fichier $filename en lecture";
|
|
|
+ while (my $line = <$fh>)
|
|
|
+ {
|
|
|
+ return $line;
|
|
|
+ }
|
|
|
+ close $fh;
|
|
|
+}
|
|
|
+
|
|
|
+# Lis le fichier contenant les nombres adh/abo d'un FAI
|
|
|
+sub adh {
|
|
|
+ my $fai = shift @_;
|
|
|
+ my $filename = "/home/canouan/bot-irc/". $wrk_dir."/". $fai.".adh";
|
|
|
+ my $fh;
|
|
|
+ open ($fh, '<', $filename) or die "Impossible d'ouvrir le fichier $filename en lecture";
|
|
|
+ while (my $line = <$fh>)
|
|
|
+ {
|
|
|
+ return $line;
|
|
|
+ }
|
|
|
+ close $fh;
|
|
|
+}
|
|
|
+
|
|
|
+# lis le fichier avec les infos pour la réunion de suivi
|
|
|
+sub suivi {
|
|
|
+ my $filename = "/home/canouan/bot-irc/". $wrk_dir."/suivi";
|
|
|
+ my $fh;
|
|
|
+ open ($fh, '<', $filename) or die "Impossible d'ouvrir le fichier $filename en lecture";
|
|
|
+ while (my $line = <$fh>)
|
|
|
+ {
|
|
|
+ return $line;
|
|
|
+ }
|
|
|
+ close $fh;
|
|
|
+}
|
|
|
+
|
|
|
+## Le bot lit le chan et réagit
|
|
|
+sub said {
|
|
|
+ my ($self, $message) = @_;
|
|
|
+ # si on veut des info
|
|
|
+ if ($message->{body} =~ /^\+info/) {
|
|
|
+ shift @_;
|
|
|
+ # Apinnet
|
|
|
+ if($message->{body} =~ /(ap[in]|Poitou|Charente|Rochelle|(Deux[- ])?S[èe]vres?|Vienne|Angoul[eêè]me|Niort|Poitiers)/) {
|
|
|
+ return "site : http://www.apinnet.fr/ salon : irc://irc.geeknode.org/#Apinnet dans le Poitou-Charentes";
|
|
|
+ }
|
|
|
+ elsif($message->{body} =~ /\btest/) {
|
|
|
+ info ("ilico");
|
|
|
+ }
|
|
|
+ # Aquilenet
|
|
|
+ elsif($message->{body} =~ /\b(aq(ui|n)|Bord(o|e?au)|Landes|Gironde)/i) {
|
|
|
+ info ("aquilenet");
|
|
|
+ }
|
|
|
+ # ARN
|
|
|
+ elsif($message->{body} =~ /\b(a(lsace|rn)|Stras|Colma)/i) {
|
|
|
+ info("arn");
|
|
|
+ }
|
|
|
+ # Auvernet
|
|
|
+ elsif($message->{body} =~ /\b(Auver|Puy[- ](de[- ])D[oô]me|avn)/i) {
|
|
|
+ info ("auvernet");
|
|
|
+ }
|
|
|
+ # Cafai
|
|
|
+ elsif($message->{body} =~ /\b(cafai|champagne|ardenn?e)/i) {
|
|
|
+ info("cafai");
|
|
|
+ }
|
|
|
+ # faimaison
|
|
|
+ elsif($message->{body} =~ /\b(fma|fail?m|Nantes|Loire[- ]Atlantique)/i) {
|
|
|
+ info ("faimaison");
|
|
|
+ }
|
|
|
+ # FDN
|
|
|
+ elsif($message->{body} =~ /\bf(rench|dn)/i) {
|
|
|
+ return"French Data Network, site : http://www.fdn.fr/ salon : irc://irc.geeknode.org/#fdn. Partout en France Métropolitaine" ;
|
|
|
+ }
|
|
|
+ # franciliens.net
|
|
|
+ elsif($message->{body} =~ /\b(f(ranc|cn)|idf|Paris)/i) {
|
|
|
+ info ("franciliens");
|
|
|
+ }
|
|
|
+ # grifon
|
|
|
+ elsif($message->{body} =~ /\b(grif|rennes|[îi]l?le[- ](et[- ])?vilaine)/i) {
|
|
|
+ info("grifon");
|
|
|
+ }
|
|
|
+ # ilico
|
|
|
+ elsif($message->{body} =~ /\b(ilc|ill?[iy][ck])|(Corr?[éêèe][sz])/i) {
|
|
|
+ info("ilico");
|
|
|
+ }
|
|
|
+ # illyse
|
|
|
+ elsif($message->{body} =~ /\b(ill?y|ill?i[sz]|lyon|rh[ôo]ne|loire|((st|saint)[- ]etienn?e))/i) {
|
|
|
+ info ("illyse");
|
|
|
+ }
|
|
|
+ # iloth
|
|
|
+ elsif($message->{body} =~ /\b(ilo|mont?pel|h[ée]rault)/i) {
|
|
|
+ info("iloth");
|
|
|
+ }
|
|
|
+ # ldn
|
|
|
+ elsif($message->{body} =~ /\b(l(or|dn)|Nancy|Metz|Moselle|Meuse|Meurthe|Vosges)/i) {
|
|
|
+ info("ldn");
|
|
|
+ }
|
|
|
+ # ndn
|
|
|
+ elsif($message->{body} =~ /\b(n(ice|dn)|Antibes|Cannes|Valbonne|Alpes[- ]Maritimes)/i) {
|
|
|
+ info("ldn");
|
|
|
+ }
|
|
|
+ # netopi
|
|
|
+ elsif($message->{body} =~ /\b(netopi|Seine[- ](et[- ])?Marne)/i) {
|
|
|
+ return "Netopi = site : http://netopi.fr ; pas de salon ; en Seine et Marne";
|
|
|
+ }
|
|
|
+ # pclight
|
|
|
+ elsif($message->{body} =~ /\b(yonne|beon|cheny|pc[- ]?l)/i) {
|
|
|
+ info("pclight");
|
|
|
+ }
|
|
|
+ # rézine
|
|
|
+ elsif($message->{body} =~ /\b(r[eé]z|Isère|Grenoble)/i) {
|
|
|
+ info("rezine");
|
|
|
+ }
|
|
|
+ # rhizome
|
|
|
+ elsif($message->{body} =~ /\b(rh?[iy][sz]om|Oise|Compi[eéêè]gne)/i) {
|
|
|
+ info("rhizome");
|
|
|
+ }
|
|
|
+ # sames
|
|
|
+ elsif($message->{body} =~ /\bsam|(Pyrénées[- ]Atlantiques)/i) {
|
|
|
+ info("sames");
|
|
|
+ }
|
|
|
+ # sdn
|
|
|
+ elsif($message->{body} =~ /\b(s(all|dn)|Savoie|Haute[- ]Savoie)/i) {
|
|
|
+ return"Sallanches Data Network = siteweb : http://sdnet.info/ ; pas de salon ; à Sallanches (73)";
|
|
|
+ }
|
|
|
+ # teleragno
|
|
|
+ elsif($message->{body} =~ /\b(mars|telerag|telegrano)/i) {
|
|
|
+ info ("teleragno");
|
|
|
+ }
|
|
|
+ # tetaneutral
|
|
|
+ elsif($message->{body} =~ /\b(t(eta|tn|nn)|Toulouse|Comminges|(Haute[- ]Garon?ne))/i) {
|
|
|
+ info ("tetaneutral");
|
|
|
+ }
|
|
|
+ # ail-network
|
|
|
+ elsif($message->{body} =~ /\bail/i) {
|
|
|
+ return "Aïl-network = siteweb : http://ail-network.org/ ; pas de salon ; Tarn Sud-Est (Pays d'Autan)";
|
|
|
+ }
|
|
|
+ # chaul'hertz
|
|
|
+ elsif($message->{body} =~ /\b(c(haul|hz)|hertz|tarn|autan)/i) {
|
|
|
+ return "Chaul'Hertz = pas de site ni de salon ; Chauley, hameau à St Maurice en Rivière (71)";
|
|
|
+ }
|
|
|
+ # igwan
|
|
|
+ elsif($message->{body} =~ /\b(ig[wn]|sbg|saint[- ]barth)/i) {
|
|
|
+ info ("igwan");
|
|
|
+ }
|
|
|
+ # neutrinet
|
|
|
+ elsif($message->{body} =~ /\b(neutri|n[tre]n|belgique)/i) {
|
|
|
+ info("neutrinet");
|
|
|
+ }
|
|
|
+ elsif($message->{body} =~ /\bf(ede|fdn|rance|édé)/i) {
|
|
|
+ return "La federation FDN est une asso qui regroupe des FAIs associatifs";
|
|
|
+ }
|
|
|
+
|
|
|
+ # Si le FAI n'est pas valide, on l'indique
|
|
|
+ else {
|
|
|
+ return "commande : +info <fai> ou +info <lieu geographique>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ # si on veut le nombre d'adhérent
|
|
|
+ elsif ($message->{body} =~ /^\+adh/) {
|
|
|
+ shift @_;
|
|
|
+
|
|
|
+ # Apinnet
|
|
|
+ if($message->{body} =~ /\b(ap[in]|Poitou|Charente|Rochelle|(Deux[- ])?S[èe]vres?|Vienne|Angoul[eêè]me|Niort|Poitiers)/i) {
|
|
|
+ return "Aucune info pour apinnet";
|
|
|
+ }
|
|
|
+ # Aquilenet
|
|
|
+ elsif($message->{body} =~ /\b(aq(ui|n)|Bord(o|e?au)|Landes|Gironde)/i) {
|
|
|
+ adh ("aquilenet");
|
|
|
+ }
|
|
|
+ # ARN
|
|
|
+ elsif($message->{body} =~ /\b(a(lsace|rn)|Stras|Colma)/i) {
|
|
|
+ adh("arn");
|
|
|
+ }
|
|
|
+ # Auvernet
|
|
|
+ elsif($message->{body} =~ /\b(Auver|Puy[- ](de[- ])D[oô]me|avn)/i) {
|
|
|
+ adh ("auvernet");
|
|
|
+ }
|
|
|
+ # Cafai
|
|
|
+ elsif($message->{body} =~ /\b(cafai|champagne|ardenn?e)/i) {
|
|
|
+ adh("cafai");
|
|
|
+ }
|
|
|
+ # faimaison
|
|
|
+ elsif($message->{body} =~ /\b(fma|fail?m|Nantes|Loire[- ]Atlantique)/i) {
|
|
|
+ adh ("faimaison");
|
|
|
+ }
|
|
|
+ # FDN
|
|
|
+ elsif($message->{body} =~ /\bf(rench|dn|rance)/) {
|
|
|
+ return "Aucune info pour FDN";
|
|
|
+ }
|
|
|
+ # franciliens.net
|
|
|
+ elsif($message->{body} =~ /\b(f(ranc|cn)|idf|Paris)/i) {
|
|
|
+ adh ("franciliens");
|
|
|
+ }
|
|
|
+ # grifon
|
|
|
+ elsif($message->{body} =~ /\b(grif|rennes|[îi]l?le[- ](et[- ])?vilaine)/i) {
|
|
|
+ adh("grifon");
|
|
|
+ }
|
|
|
+ # ilico
|
|
|
+ elsif($message->{body} =~ /\b(ilc|ill?[iy][ck])|(Corr?[éêèe][sz])/i) {
|
|
|
+ adh("ilico");
|
|
|
+ }
|
|
|
+ # illyse
|
|
|
+ elsif($message->{body} =~ /\b(ill?y|ill?i[sz]|lyon|rh[ôo]ne|loire|((st|saint)[- ]etienn?e))/i) {
|
|
|
+ adh ("illyse");
|
|
|
+ }
|
|
|
+ # iloth
|
|
|
+ elsif($message->{body} =~ /\b(ilo|mont?pel|h[ée]rault)/i) {
|
|
|
+ adh("iloth");
|
|
|
+ }
|
|
|
+ # ldn
|
|
|
+ elsif($message->{body} =~ /\b(l(or|dn)|Nancy|Metz|Moselle|Meuse|Meurthe|Vosges)/i) {
|
|
|
+ adh("ldn");
|
|
|
+ }
|
|
|
+ # ndn
|
|
|
+ elsif($message->{body} =~ /\b(n(ice|dn)|Antibes|Cannes|Valbonne|Alpes[- ]Maritimes)/i) {
|
|
|
+ adh("ldn");
|
|
|
+ }
|
|
|
+ # netopi
|
|
|
+ elsif($message->{body} =~ /\b(netopi|Seine[- ](et[- ])?Marne)/i) {
|
|
|
+ return "Netopi = site : http://netopi.fr ; pas de salon ; en Seine et Marne";
|
|
|
+ }
|
|
|
+ # pclight
|
|
|
+ elsif($message->{body} =~ /\b(yonne|beon|cheny|pc[- ]?l)/i) {
|
|
|
+ adh("pclight");
|
|
|
+ }
|
|
|
+ # rézine
|
|
|
+ elsif($message->{body} =~ /\b(r[eé]z|Isère|Grenoble)/i) {
|
|
|
+ adh("rezine");
|
|
|
+ }
|
|
|
+ # rhizome
|
|
|
+ elsif($message->{body} =~ /\b(rh?[iy][sz]om|Oise|Compi[eéêè]gne)/i) {
|
|
|
+ adh("rhizome");
|
|
|
+ }
|
|
|
+ # sames
|
|
|
+ elsif($message->{body} =~ /\bsam|(Pyrénées[- ]Atlantiques)/i) {
|
|
|
+ adh("sames");
|
|
|
+ }
|
|
|
+ # sdn
|
|
|
+ elsif($message->{body} =~ /\b(s(all|dn)|Savoie|Haute[- ]Savoie)/i) {
|
|
|
+ return "aucune info pour SDN";
|
|
|
+ }
|
|
|
+ # teleragno
|
|
|
+ elsif($message->{body} =~ /\b(mars|telerag|telegrano)/i) {
|
|
|
+ adh ("teleragno");
|
|
|
+ }
|
|
|
+ # tetaneutral
|
|
|
+ elsif($message->{body} =~ /\b(t(eta|tn|nn)|Toulouse|Comminges|(Haute[- ]Garon?ne))/i) {
|
|
|
+ adh ("tetaneutral");
|
|
|
+ }
|
|
|
+ # ail-network
|
|
|
+ elsif($message->{body} =~ /\bail/i) {
|
|
|
+ return "aucune info pour Aïl-network";
|
|
|
+ }
|
|
|
+ # chaul'hertz
|
|
|
+ elsif($message->{body} =~ /\b(c(haul|hz)|hertz|tarn|autan)/i) {
|
|
|
+ return "aucune info pour Chaul-Hertz";
|
|
|
+ }
|
|
|
+ # igwan
|
|
|
+ elsif($message->{body} =~ /\b(ig[wn]|sbg|saint[- ]barth)/i) {
|
|
|
+ adh ("igwan");
|
|
|
+ }
|
|
|
+ # neutrinet
|
|
|
+ elsif($message->{body} =~ /\b(neutri|n[tre]n|belgique)/i) {
|
|
|
+ adh("neutrinet");
|
|
|
+ }
|
|
|
+ elsif($message->{body} =~ m{\bf(ede|fdn|rance|édé)}i) {
|
|
|
+ return "Not yet";
|
|
|
+ }
|
|
|
+
|
|
|
+ # Si le FAI n'est pas valide, on l'indique
|
|
|
+ else {
|
|
|
+ return "commande : +adh <fai> ou +adh <lieu geographique>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ # si on veut de l'aide
|
|
|
+ elsif ($message->{body} =~ /^\+help/) {
|
|
|
+ return "pour les infos +info - pour les nombres d'adhérent·e·s et d'abonné·e·s +adh - pour les informations par rapport aux réunios de suivi +suivi - pour les sources du bot +source";
|
|
|
+ }
|
|
|
+ # les sources du bot
|
|
|
+ elsif ($message->{body} =~ /^\+source/) {
|
|
|
+ return "http://gitorious.com";
|
|
|
+ }
|
|
|
+ # les infos par rapport aux réunions de suivies
|
|
|
+ elsif ($message->{body} =~ /^\+suivi/) {
|
|
|
+ suivi;
|
|
|
+ }
|
|
|
+ elsif ($message->{body} =~ /datafoin/) {
|
|
|
+ return "il ne faut pas me donner à manger après minuit";
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+# tout ce qu'on écrit dans /tmp/log apparait dans $channel
|
|
|
+my $channel = '#bottestbot';
|
|
|
+sub connected {
|
|
|
+# my $channel = shift;
|
|
|
+ my $self = shift;
|
|
|
+ $self->forkit({ channel => $channel,
|
|
|
+ run => [ qw( /usr/bin/tail -f /tmp/log ) ],
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+# aucune idée de comment on déclenche cette ligne
|
|
|
+sub help { "Je suis le bot de la fédé." }
|
|
|
+
|
|
|
+#Info de connexion du bot
|
|
|
+MyBot->new(
|
|
|
+ server => 'irc.geeknode.org',
|
|
|
+ channels => [ '#bottestbot'],
|
|
|
+ nick => 'UneFede',
|
|
|
+ username => 'bot',
|
|
|
+ name => 'Droide de la Federation FDN, run by Vigdis'
|
|
|
+ )->run();
|