#!perl -w =head1 NAME aoliza_ripoff.plx =head1 SYNOPSIS Watch silly users talk to Eliza. =head1 DESCRIPTION I read about this AOLiza thing where someone used AppleScript and Perl to set up an Eliza bot on AOL Instant Messenger. http://fury.com/aoliza/ I couldn't find the source and wrote my own. You need AOL Instant Messenger and MacPerl (with Chatbot::Eliza, Mac::Glue, and the latest Mac::AppleEvents::Simple). If Mac::AppleEvents::Simple 0.83 is not yet on CPAN yet, get it here: http://pudge.net/files/macperl/temp/Simple.pm Also, you need a short little AppleScript that contains this: on «event OscrNuIM» theIM tell application "MacPerl" to «event OscrNuIM» theIM end «event OscrNuIM» Save the script in your Scripts folders and set it as the handler for "New message arrives" and "message arrives". Also set your prefs to open incoming IMs and not require the knock-knock thingy. =cut use Chatbot::Eliza; use Mac::AppleEvents::Simple 0.83; # for handle_event use Mac::Glue ':all'; use strict; =pod Create a glue for AOL IM (I called my glue "AOLIM"). Give your bot the same name as your AOL IM user. Decide if you want separate bots for each user that sends you an IM (which makes the bot seem a bit more reasonable), or to share one for all users. Run the script, and leave it running, and enjoy. You could use a separate copy of MacPerl to leave it running if you don't want to dedicate MacPerl to this full-time. =cut my $aolim = new Mac::Glue 'AOLIM'; # name of my AOLIM glue my $botname = 'MYUSER'; # AOL IM user name my $separate = 1; # separate bots for each nick my(@im_out, %bots); handle_event('Oscr', 'NuIM', \&handler); while (1) { if (my $im = shift @im_out) { sleep(rand 8); my($nick, $text) = @$im; my $bot = get_bot($nick); # print "[$nick] [$text] [$bot]\n"; $aolim->sendim( screenname => $nick, message => $bot->transform($text), sendnow => 1 ); } } sub get_bot { my $nick = $separate ? shift : 1; if (!exists $bots{$nick}) { my $bot = new Chatbot::Eliza; $bot->name($botname); $bots{$nick} = $bot; for ('asl', 'a/s/l') { $bot->{keyranks}{$_} = 10; push @{$bot->{decomplist}{$_}}, '*'; push @{$bot->{reasmblist}{$_, '*'}}, "I don't tell strangers my age.", "I don't tell strangers where I live.", "How old do you want me to be?", "Female, of course. Men don't think.", "You first.", "23/m/pa", "99/q/mars", "33/yes/where should I be?"; } } return $bots{$nick}; } sub handler { my($evt) = @_; my @im = $evt->get; my $id = $im[0]; my $text = strip_html($im[9]); push @im_out, [$id, $text] if $id && $text; } # yes, should be improved sub strip_html { local $_ = shift; s/<[^>]*>//g; return $_; } __END__ =head1 HISTORY =over 4 =item v1.0.0, Tuesday, August 29, 2000 First version. Basically just tailed existing log files looking for new IMs. =item v2.0.0, Wednesday, August 30, 2000 Rewrite using an Apple event handler (wow, it is cool that AOL IM does some of this stuff). =back =head1 AUTHOR Chris Nandor Epudge@pobox.comE, http://pudge.net/ Copyright (c) 2000 Chris Nandor. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License, distributed with Perl. =head1 VERSION 2.0.2, Friday, September 1, 2000