From 68053cfca17c3b1e946ed6752ad8b4dffa77bf31 Mon Sep 17 00:00:00 2001 From: timriker Date: Thu, 24 Feb 2005 22:28:29 +0000 Subject: [PATCH] iglatinpay git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1175 c11ca15a-4712-0410-83d8-924469b57eb5 --- files/sample/blootbot.chan | 3 ++- src/CommandStubs.pl | 3 +++ src/Modules/piglatin.pl | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/Modules/piglatin.pl diff --git a/files/sample/blootbot.chan b/files/sample/blootbot.chan index 7e6e47c..f35c70b 100644 --- a/files/sample/blootbot.chan +++ b/files/sample/blootbot.chan @@ -1,4 +1,4 @@ -#v1: blootbot -- infobot -- written Tue Feb 22 05:10:22 2005 +#v1: blootbot -- blootbot -- written Thu Feb 24 22:25:12 2005 #botpark +RootWarn @@ -66,6 +66,7 @@ _default minVolunteerLength 50 +nickometer +pager + +piglatin randomFactoidInterval 60 randomQuoteInterval 60 +scramble diff --git a/src/CommandStubs.pl b/src/CommandStubs.pl index eb8e7df..7d6f62c 100644 --- a/src/CommandStubs.pl +++ b/src/CommandStubs.pl @@ -283,6 +283,9 @@ sub parseCmdHook { &addCmdHook("extra", 'dns|d?nslookup|host', ('CODEREF' => 'dns::query', 'Identifier' => 'dns', 'Cmdstats' => 'dns', 'Forker' => 1, 'Help' => 'dns') ); +&addCmdHook("extra", 'piglatin', ('CODEREF' => 'piglatin::piglatin', + 'Identifier' => 'piglatin', 'Cmdstats' => 'piglatin', + 'Forker' => 1) ); ### ### END OF ADDING HOOKS. ### diff --git a/src/Modules/piglatin.pl b/src/Modules/piglatin.pl new file mode 100644 index 0000000..27830e0 --- /dev/null +++ b/src/Modules/piglatin.pl @@ -0,0 +1,37 @@ +# turns english text into piglatin +# Copyright (c) 2005 Tim Riker + +use strict; +use warnings; + +package piglatin; + +sub piglatin +{ + my ($text) = @_; + my $piglatin; + my $suffix = 'ay'; + + # FIXME: does not handle: + # punctuation and hyphens + # y as vowel "style" -> "ylestay" + # contractions + for my $word (split /\s+/, $text) { + my $pigword; + if ($word =~ /^(qu)(.*)/ ) { + $pigword = "$2$1$suffix"; + } elsif ($word =~ /^(Qu)(.)(.*)/ ) { + $pigword = uc($2) . $3 . lc($1) . $suffix; + } elsif ($word =~ /^([bcdfghjklmnpqrstvwxyz]+)(.*)/ ) { + $pigword = "$2$1$suffix"; + } elsif ($word =~ /^([BCDFGHJKLMNPQRSTVWXYZ])([bcdfghjklmnpqrstvwxyz]*)([aeiouy])(.*)/ ) { + $pigword = uc($3) . $4 . lc($1) . $2 . $suffix; + } else { + $pigword = $word . 'w' . $suffix; + } + $piglatin .= " $pigword"; + } + &::performStrictReply($piglatin||'failed'); +} + +1; -- 2.39.5