#!/usr/bin/perl -w
# $File: //depot/libOurNet/FuzzyIndex/bin/fianjmo $ $Author: autrijus $
# $Revision: #1 $ $Change: 1 $ $DateTime: 2002/06/11 15:35:12 $

$VERSION = '1.03';

=head1 NAME

fianjmo - Chat with a virtual personality

=head1 SYNOPSIS

B<fianjmo> S<[ I<personality> ]>

=head1 DESCRIPTION

Just run F<fianjmo> at command line, enter any sentence, press enter,
and repeat. Press Ctrl-D to terminate the conversation.

=head1 CAVEATS

The default script generated by C<make test> is in zh_TW.Big5 charset.
To any other terminal it might be unintelligible.

=cut

use strict;
use OurNet::ChatBot;

my $bot = eval { OurNet::ChatBot->new(
    'fianjmo', 
    'fianjmo.'.($ARGV[0] ? "$ARGV[0]." : '').'db' 
)};

$bot->{nextone}++;

if ($@ or !$bot->{db}{idxcount}) {
    die "No database found. ($@)\n";
}

print "*** Joined channel #fianjmo. Enter /bye to quit.\n";
print '['.($ENV{USER} || 'user').'] ';

while (<STDIN>) {
    exit if /^\/b(?:ye)?/;
    print '<fianjmo> '.($bot->input($_) || 'лC')."\n"
	unless /^[\s\t]*$/;
    print '['.($ENV{USER} || 'user').'] ';
}

1;

__END__

=head1 AUTHORS

Autrijus Tang E<lt>autrijus@autrijus.orgE<gt>

=head1 COPYRIGHT

Copyright 2001 by Autrijus Tang E<lt>autrijus@autrijus.orgE<gt>.

This program is free software; you can redistribute it and/or 
modify it under the same terms as Perl itself.

See L<http://www.perl.com/perl/misc/Artistic.html>

=cut
