]> git.donarmstrong.com Git - infobot.git/commitdiff
iglatinpay
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 24 Feb 2005 22:28:29 +0000 (22:28 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 24 Feb 2005 22:28:29 +0000 (22:28 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1175 c11ca15a-4712-0410-83d8-924469b57eb5

files/sample/blootbot.chan
src/CommandStubs.pl
src/Modules/piglatin.pl [new file with mode: 0644]

index 7e6e47cc044674f44b8462f7f2dc4dd23863f8ae..f35c70b7601dbba942b482b1caac61402f6720a2 100644 (file)
@@ -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
index eb8e7df4adcbe0395d27f16a947c53ae5817fc27..7d6f62cce573f1f79d5146c4aa222687356d2388 100644 (file)
@@ -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 (file)
index 0000000..27830e0
--- /dev/null
@@ -0,0 +1,37 @@
+# turns english text into piglatin
+# Copyright (c) 2005 Tim Riker <Tim@Rikers.org>
+
+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;