User Control Panel
Advertisements

HELP US, HELP YOU!

PigLatin filter for Cerebrus

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Modules & Add Ons
View unanswered posts
Author Message
eric256
The Keymaker
The Keymaker


Joined: 03 May 2006
Posts: 2292
Location: Colorado
Reputation: 47Reputation: 47Reputation: 47Reputation: 47Reputation: 47

PostPosted: Thu Jun 22, 2006 3:46 am    Post subject: PigLatin filter for Cerebrus Reply with quote

Yo!

Alright so after a little piglatin challenge today I decided to make a pig latin filter. It is incredibly simple to do. So without further ado!

Code:

package Filters::PigLatin;

sub new {
   my $proto = shift;
   my $self = { };   
   bless $self, $proto;
   return $self;
}

sub filter {
   my $self      = shift;
   my $context = shift;
   
   foreach (@{$context->{Input}}) {
      s/(\w*?)([aeiou]\w*)/$2$1ay/g;
      push @{$context->{Output}}, $_;
   }
   $context->{Input} = [];
   return 1;
}
1;


That is basicaly it. You make a pakage in the Filters:: namespace. Give it new and filter methods. The filter method takes a reference to the filter object itself and to the context objects. Context objects store all the data about a conversation that you could ever want. Two things in specifc are the Input and the Ouput arrays. This filter takes everything thats in the Input array, converts it to pig latin, and then pushes it onto the output filter. Finaly it clears the input so that filters later on wont try to process the same input.


All that is lef then is to modify your config.xml file to add the filter,
Code:
<Filter Name="PigLatin"  />

Put that somewhere after you've processed your commands and input...i put mine where blab normaly sits Wink

_________________
Eric256
Proud previous owner and current admin of Bot-depot.com
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Modules & Add Ons All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group