#!/usr/bin/perl #use strict; use IO::Socket; #require "parser.pl"; my $mycharacter = "NameOfCharacterYouUse"; my $voicecharacter = "NameOfExtraCharacter"; my $voicepasswd = "ExtraCharacterPassword"; my %names; my $DEBUG = 1; my %voices = ("sarahdipity" => "Agnes", "Q*Bert" => "Fred", "fenchurch" => "Victoria", "whisper" => "Whisper", "EvilKnarf" => "Ralph", "Loa" => "Princess", "Nire" => "Agnes", "PitfallHarry" => "Bruce", "The Dude" => "Albert", "2sheds" => "Agnes", "sam" => "Princess", "Neil" => "Zarvox", #----------------------# "You" => "Zarvox", "narrator" => "Bruce"); my %substitutions = ("2sheds" => "two-sheds", "EvilKnarf" => "evil-narf", "Satan" => "saytan"); $sock = new IO::Socket::INET(PeerAddr => 'forest.moo.mud.org', PeerPort => 7779, Proto => 'tcp' ); print $sock "\@connect $voicecharacter $voicepasswd\n"; print $sock "join $mycharacter\n"; print $sock "follow $mycharacter\n"; while ($nextline = <$sock>){ chop $nextline; chop $nextline; print "$nextline\n"; parse($nextline); } close $sock; #---------------------- sub parse{ my ($line) = @_; my ($voice); if($line =~ /^\#/){ print "Comment ignored\n" if $DEBUG; } elsif($line =~ /^$/){ print "Empty line ignored\n" if $DEBUG; } elsif($line =~ /^(.*) says, "(.*)"/){ print "Speech: $1 said $2\n" if $DEBUG; $names{$1} = 1; if(exists($voices{$1})){ $voice = $voices{$1} }else{$voice = "Bruce"} say("$1 says,", "$voices{'narrator'}"); say("$2", "$voice"); } elsif($line =~ /^(.*) \[to (.*)\]: (.*)/){ print "Directed speech: $1 to $2: $3\n"; $names{$1} = 1; $names{$2} = 1; if(exists($voices{$1})){ $voice = $voices{$1} }else{$voice = "Bruce"} say("$1, to $2:", "Bruce"); say("$3", "$voice"); } elsif($line =~ /$mycharacter whispers to you, "(.*)"/){ print "Doing a command\n"; do_action($1); } elsif($line =~ /(.*) \| (.*)/){ print "Pipe-paste from $1.\n"; } elsif($line =~ /(.*) . o O \( (.*) \)/){ print "Looks like a think\n"; $names{$1} = 1; if(exists($voices{$1})){ $voice = $voices{$1} }else{$voice = "Bruce"} say("$1 thinks,", "Bruce"); say("$2", "$voice"); } elsif(($line =~ /^(\S+)/) && (exists($names{$1}))){ print "Must be an emote\n"; say($line, $voices{'narrator'}); } else{ print "Unknown line\n" if $DEBUG; } } sub say{ my ($line, $voice) = @_; $line =~ s/"/\\"/g; $line =~ s/'//g; #' foreach $key (keys(%substitutions)){ $line =~ s/$key/$substitutions{$key}/g; } print "Saying - $line - as $voice\n"; system("osascript -e 'say \"$line\" using \"$voice\"'"); } sub do_action{ print "Doing @_[0]\n"; print $sock "@_[0]\n"; }