Skip Menu |

This queue is for tickets about the Bot-BasicBot-Pluggable CPAN distribution.

Report information
The Basics
Id: 46875
Status: resolved
Priority: 0/
Queue: Bot-BasicBot-Pluggable

People
Owner: MDOM [...] cpan.org
Requestors: jakob.voss [...] gbv.de
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Support use of modules without a bot
The pluggable architecture of modules is useful, but why should you limit it it IRC only? I'd like to use modules also use in other domains (Jabber, Twitter, Web-Applications etc.). The only problem I encountered is that the ->bot method of a module croaks if you used the module in other environments and so does the ->store method. I'd suggest to rewrite the ->store method to use an in-memory store by default. Here is a testcase : my $mod = Bot::BasicBot::Pluggable::Module::MyModule->new(); $mod->set( "foo" => "bar" ); print "> "; while (<STDIN>) { last if $_ =~ /^(quit|bye|exit)$/; my $reply = $mod->told( $_ ); print "$reply\n" if defined $reply; print "> "; }
I found out you get the behaviour I needed if you rewrite the store method: sub store { my $self = shift; return $self->bot->store if $self->bot; return $self->{defaultstore} if $self->{defaultstore}; $self->{defaultstore} = Bot::BasicBot::Pluggable::Store::Storable->new(); return $self->{defaultstore}; } I suggest to do this as default in Bot::BasicBot::Pluggable:Module. Please note that you must set the 'Name' property of a module if you override the constructor. I just call the constructor of Bot::BasicBot::Pluggable::Module in a derived module class: sub new { my $class = shift; $class = ref($class) || $class; my $self = Bot::BasicBot::Pluggable::Module::new( $class ); $self->set( @_ ) if @_; return $self; }
Hello! Thanks for the suggestion, i would have never dreamed about anyone using modules like this... :) Maybe it would be the easiest way to just use Test::Bot::BasicBot::Pluggable to interface with your modules as it does try to mimick the normal bot behaviour in any regard like $bot->store, $bot->nick etc. my $bot = Test::Bot::BasicBot::Pluggable->new(); $bot->load('Karma'); $bot->tell_directly('karma alice') # => alice has karma of 0. Let me know what you think about this! Best wishes, Mario
 v0.83 contains the cli bot again