Hubot::Brain - Represents somewhat persistent storage for the robot.
$robot->brain->{data}{key} = ''; # scalar $robot->brain->{data}{key} = {}; # HashRef $robot->brain->{data}{key} = []; # ArrayRef
Brain with external storage like a Hubot::Scrips::redisBrain, value must be a Scalar or HashRef or ArrayRef.
value
$robot->brain->data will convert to json string and stored to external storage. so, if you trying to store perl object, it will fail.
$robot->brain->data
without external storage, everything is fine to store to memory.
subscribe brain's save and close event.
save
close
robot boots time, save will emitted. robot shutdown time, close will emitted.
my $externalStorage = Great::Big::White::World->new; $robot->brain->on( 'save', sub { my ($e, $data) = @_; $externalStorage->save($data); } ); $robot->brain->on( 'close', sub { $externalStorage->quit; } );
Hubot::Scripts::redisBrain
Hyungsuk Hong <hshong@perl.kr>
This software is copyright (c) 2012 by Hyungsuk Hong.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Hubot, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hubot
CPAN shell
perl -MCPAN -e shell install Hubot
For more information on module installation, please visit the detailed CPAN module installation guide.