Tässä pieni scripti irssille, joka puhuu kaiken kanavalle sanotun tekstin suomeksi.
!HUOM! - tämä ei ole mun tekemä, olen vain törkeästi muokannut alkuperäistä festival.pl scriptiä (tekijän tiedot scriptin headereissä)
#! /usr/bin/perl -w
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = "0.1fin";
%IRSSI = (
authors => 'Andrzej Zaborowski',
contact => 'balrog@zabor.org',
name => 'festival',
description => 'Sends channel messages to the speech daemon',
license => 'BSD',
url => 'http://www.zabor.org/balrog',
);
use Irssi;
my $saycmd = "iconv -f UTF-8 -t ISO8859-1 /tmp/ttv > /tmp/ttv2 && festival --tts /tmp/ttv2";
my $log = "~/.irssi/festival.log";
sub mangle_string {
my ($msg) = @_;
$msg =~ s/\'//g;
$msg =~ s/\`//g;
$msg =~ s/\:\)/ /g;
$msg =~ s/\;/ /g;
$msg =~ s/\(/ /g;
$msg =~ s/\)/ /g;
$msg =~ s/\;[()]/ /g;
$msg =~ s/\:\// /g;
$msg =~ s/\:\>/ /g;
$msg =~ s/\:D/ /g;
$msg =~ s/\:keskisormi:/ /g;
$msg =~ s/\:p/ /g;
$msg =~ s/\prkl/peruna/g;
$msg =~ s/\http:*/ /g;
$msg =~ s/\jne/jii än ee/g;
$msg =~ s/\www./vee vee vee piste/g;
$msg =~ s/\:[Yy][Ee][Ss]:/jees/g;
$msg =~ s/\:[Nn][Oo]:/nou/g;
$msg =~ s/[Ll][Oo][Ll]/ /g;
$msg =~ s/[Ee][Vv][Oo]/et vaa osaa/g;
$msg =~ s/[Vv][Mm][Pp]/hitto mitä roskaa/g;
$msg =~ s/btw/baitevei/g;
$msg =~ s/wtf/ vattefak /g;
$msg =~ s/yes/jees/g;
$msg =~ s/£/punta/g;
$msg =~ s/[Mm]icrosoft/maikrosoft/g;
$msg =~ s/:[Tt][Uu][Oo][Pp][Pp][Ii]:/ /g;
$msg =~ s/fuck/fak/g;
$msg =~ s/[1234567890][1234567890]:[1234567890][1234567890]/kellon aika/g;
$msg =~ s/[Rr][Tt][Ff][Mm]/lue manuska/g;
$msg =~ s/hm*/mmm/g;
$msg =~ s/^/ /g;
$msg =~ s/=/ = /g;
$msg =~ s/IP/ iipee /g;
$msg =~ s/DRI/ dee är ii /g;
$msg =~ s/opengl/ ouppen gee äl /g;
$msg =~ s/glxgears/ gee äl äks gears /g;
$msg =~ s/glxinfo/ gee äl äks info /g;
$msg =~ s/thx/ /g;
$msg =~ s/([Hh][Aa])+[Hh]?/HAHAH/g;
return $msg;
}
sub message_public {
my ($server, $msg, $nick, $address, $channel) = @_;
my $twin = Irssi::window_find_item($channel);
my $awin = Irssi::active_win();
if (!defined($twin) || $twin->{refnum} ne $awin->{refnum}) {
return;
}
$msg = mangle_string($msg);
system("echo \'$nick sanoo. $msg\' > /tmp/ttv | $saycmd >> $log 2>&1 &");
}
sub message_private {
my ($server, $msg, $nick, $address, $channel) = @_;
$msg = mangle_string($msg);
system("echo \'$nick sanoo. $msg\' > /tmp/ttv | rm $log && touch $log | $saycmd >> $log 2>&1 &");
}
sub message_irc_action {
my ($server, $msg, $nick, $address, $channel) = @_;
my $twin = Irssi::window_find_item($channel);
my $awin = Irssi::active_win();
if (!defined($twin) || $twin->{refnum} ne $awin->{refnum}) {
return;
}
$msg = mangle_string($msg);
system("echo \'$nick $msg\' > /tmp/ttv | $saycmd >> $log 2>&1 &");
}
Irssi::signal_add("message public", "message_public");
Irssi::signal_add("message private", "message_private");
Irssi::signal_add("message irc action", "message_irc_action");