Achtung: Ist jetzt im Haskell-Bot von fpletz implementiert.

#!/usr/bin/perl
open(HANDLE, "/home/kiu/.xchat2/xchatlogs/rettungskapsel-#ccc.log");
open(NC, "|nc -u matrix 2323");
select((select(NC), $| = 1)[0]);

while ($record = <HANDLE>) {
}

print NC "IRCBot started";

while (1) {
    if (! ($record = <HANDLE>)) {
        sleep 1;
    }

    $_ = $record;
    if ($record =~ m/MATRIX/) {
        $record =~ s/[\'\"\*\^\|\`|\_]//g;
        $record =~ s/(.*)\t//;
        $record =~ s/\((.*)\) has//;
        $record =~ s/MATRIX//;
        $record =~ s/ä/ae/;
        $record =~ s/ü/ue/;
        $record =~ s/ö/oe/;
        $record =~ s/Ä/Ae/;
        $record =~ s/Ü/Ue/;
        $record =~ s/Ö/Oe/;
        $record =~ s/ß/ss/;

        print "$record";
        print NC "$record";
    }

}

close(HANDLE);
close(NC);
#!/usr/bin/perl

use Socket;

my %opt = ( "hostname" => "matrix", "hostport" => 2323, "filename" => "/home/kiu/.xchat2/xchatlogs/rettungskapsel-#ccc.log" );

my $fh;
if ( ! open($fh,$opt{"filename"}) ) {
        die("open failed with $!\n");
};
socket(my $sh,PF_INET,SOCK_DGRAM,getprotobyname('udp'));

print "IRCBot started\n";

seek($fh,0,2);
while (1) {
        my $record = <$fh>;
        if ($record =~ m/MATRIX/) {
                $record =~ s/[\'\"\*\^\|\`|\_]//g;
                $record =~ s/(.*)\t//;
                $record =~ s/\((.*)\) has//;
                $record =~ s/MATRIX//;
                $record =~ s/ä/ae/;
                $record =~ s/ü/ue/;
                $record =~ s/ö/oe/;
                $record =~ s/Ä/Ae/;
                $record =~ s/Ü/Ue/;
                $record =~ s/Ö/Oe/;
                $record =~ s/ß/ss/;

                print "$record";
                send($sh,$record,0,sockaddr_in($opt{"hostport"},inet_aton($opt{"hostname"})));
        };
};

close($fh);

tag_projects_home

 
matrix_irc_script.txt · Last modified: 2008/10/21 12:47 by schneider