#!/usr/bin/perl # git clone http://repo.ldn-fai.net/repo/si-public.git package Bot; use base qw(Bot::BasicBot); use warnings; use strict; 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"; } exit 1; } my $nick = "accbot"; my $chan = "#fdnbotteste"; my $url = "http://fdn.ldn-fai.net"; my $file = $ARGV[0]; my $flag = "[ACC]"; my $isacc = 0; my $bot; sub said { my $self = shift; my $message = shift; return 0 unless $message->{"address"}; if($message->{"address"} eq $nick || $message->{"address"} eq "msg") { $self->reply($message, "$url - SYNTAXE : /topic N'importe quoi $flag Description de l'accident"); } } sub topic { my $self = shift; my $args = shift; if($args->{"topic"}) { if($args->{"topic"} =~ /^.*\Q$flag\E\s*(.+)$/i) { $isacc = 1; open(OUT, ">$file"); print OUT "$1"; close(OUT); $bot->emote( channel => $chan, body => "a bien reporté l'accident sur $url" ); } elsif($isacc) { $isacc = 0; open(OUT, ">$file"); print OUT ""; close(OUT); $bot->emote( channel => $chan, body => "a bien pris en compte la fin de l'accident ($url)" ); } } } $bot = Bot->new( server => "irc.geeknode.org", port => "6667", channels => [$chan], nick => $nick, alt_nicks => ["${nick}_"], username => $nick, name => $url ); $bot->run(); exit 0;