#!/usr/bin/perl #################################################### # Verbot Version 1.0 - Written by Travis Whitton # # Distribute freely as long as this notice remains # # intact. Email questions/comments to # # whitton@atlantic.net # #################################################### print "Hello, my name is Billy Bobbin!\n"; while(1) { $chat = ""; $high_priority = 0; while ($chat eq "") { printf("\x1b[1;31mChat\x1b[0;37m: "); chomp($chat = ); if ($chat eq "") { redo; } } @answer = split(/\s/, $chat); open(fh, "chat"); @response = ; foreach $word (@answer) { foreach $element (@response) { @array = split(/:/, $element); $priority = shift(@array); $answer_number = shift(@array); $answer = pop(@array); foreach $array_element(@array) { $word =~ s/[!?',.]//g; if ($array_element =~ /\b$word\b/i) { $array_element{$answer_number}+=$priority; #print "Added $priority for $array_element\n"; } } } } close(fh); $high_num = 0; $high_key = 0; foreach $key (keys (%array_element)) { if ($array_element{$key} > $high_num) { $high_num = $array_element{$key}; $high_key = $key; } } foreach $key (keys (%array_element)) { $array_element{$key} = 0; } open(fh, chat); @response = ; @winner = split(/:/, $response[$high_key]); $reply = pop(@winner); printf("\x1b[1;32mReply\x1b[0;37m: $reply"); close(fh); }