o '["help"]' > hubot-scripts.json
$ hubot
hubot> hubot help
hubot> exit
=head1 DESCRIPTION
=head2 CONFIGURATION
describe scripts name to F<hubot-scripts.json>
example)
[
"he
o '["help"]' > hubot-scripts.json
$ hubot
hubot> hubot help
hubot> exit
=head1 DESCRIPTION
=head2 CONFIGURATION
describe scripts name to F<hubot-scripts.json>
example)
[
"he
ift->done(1) }
sub TO_JSON {
my $self = shift;
return {
## prvent recursive call
## Hubot::UserTO_JSON -> Hubot::Message::TO_JSON -> Hubot::User::TO_JSON
user => {
sub match {
my ( $self, $regex ) = @_;
return $self->text =~ m/$regex/;
}
override 'TO_JSON' => sub {
my $self = shift;
return { %{ super() }, text => $self->text };
};
__PACKAGE__
must be a B<Scalar> or B<HashRef> or B<ArrayRef>.
C<$robot-E<gt>brain-E<gt>data> will convert to json string and stored to external storage.
so, if you trying to store perl object, it will fail.
wit
my ( $class, $ref ) = @_;
$ref->{name} ||= $ref->{id};
bless $ref, $class;
}
sub TO_JSON { return { %{ shift() } } }
1;
=pod
=encoding utf-8
=head1 NAME
Hubot::User - storage object
CLI. named `hubot`
$ perldoc hubot
# make sure `hubot-scripts.json` is exist in current working directory
use JSON::XS;
use Cwd 'cwd';
use Hubot::Robot;
my $robot = Hubot::Ro
ptsFile = "$cwd/hubot-scripts.json";
if (-f $scriptsFile) {
my $json = read_file($scriptsFile);
my $scripts = decode_json($json);
$robot->lo
extends 'Hubot::Adapter';
use AnyEvent;
use AnyEvent::HTTP;
use AnyEvent::Campfire::Client;
use JSON::XS;
use Encode 'encode_utf8';
use HTTP::Request;
use LWP::UserAgent;
use Try::Tiny;
use Hubot::
),
);
$req->header( 'Accept', 'application/json' );
$req->header( 'Authorization', $bot->authorization );
my $res
cess;
my $userData;
try {
$userData = decode_json( $res->content );
}
catch {
$bot->emit( 'erro
t::Scripts::tweet;
{
$Hubot::Scripts::tweet::VERSION = '0.1.3';
}
use strict;
use warnings;
use JSON::XS;
sub load {
my ( $class, $robot ) = @_;
$robot->hear(
qr/https?:\/\/(mobile\
ps://api.twitter.com/1/statuses/show/'
. $msg->match->[1]
. '.json' )->get(
sub {
my ( $body, $hdr ) = @_;
r
^2/ );
print "$body\n" if $ENV{DEBUG};
my $tweet = decode_json($body);
$msg->send("$tweet->{user}{screen_name}: $tweet->{text}");
se strict;
use warnings;
use URI;
use URI::QueryParam;
use HTTP::Request;
use LWP::UserAgent;
use JSON::XS;
use Encode 'decode';
sub load {
my ( $class, $robot ) = @_;
$robot->hear(
q
$ENV{HUBOT_BITLY_API_KEY},
longUrl => $bitly,
format => 'json'
);
my $ua = LWP::UserAgent->new;
my $req = HTTP
>request($req);
return unless $res->is_success;
my $data = decode_json( $res->content );
$bitly = $data->{data}{url};
}
$msg->h
qw(
.gitignore
Procfile
README.md
cpanfile
hubot-scripts.json
);
for my $file (@files) {
my ( $src, $dst )
= ( catfile("$dist_dir/