操作方法

Happy AnySan Hacking!

Yappo: yappo あっと shibuya.pl
Shibuya Perl Mongers

今回のYAPCは
DeNAさんが
スポンサーなので

求人PR大使をやってる
tsudaさんの
コスプレしてきました

自己紹介

AnySan is

near productions

diff of another productions

Provider

# echo bot
use AnySan::Provider::IRC;
my $irc = irc
 'chat.freenode.net',
 nickname => 'AnySan',
 channels => {
  '#danthebot' => {},
 };
AnySan->register_listener(
 echo => {
  cb => sub {
   my $receive = shift;
   $receive->send_replay($receive->message);
  }
 }
);
AnySan->run;
  
# echo bot
use AnySan::Provider::Twitter;
my $twitter = twitter
 consumer_key    => ...,
 consumer_secret => ...,
 token           => ...,
 token_secret    => ...,
 method          => 'filter',
 track           => $keyword,
 ;
AnySan->register_listener(streamer => {
 event => 'timeline',
 cb    => sub {
  my $receive = shift;
  $receive->send_replay($receive->message);
 }
});
AnySan->run;
  

AnySan::Receive

RPC系のモジュールと
組み合わせて
通知系等の能動的なbotも

# bot server
use AnyEvent::MPRPC;
use AnySan::Provider::IRC;
my $irc = irc
 'chat.freenode.net',
 nickname => 'AnySan1',
 channels => {
  '#danthebot' => {},
 };
my $server = mprpc_server '127.0.0.1', '4423';
$server->reg_cb( send => sub {
 my ($res_cv, $args) = @_;
 $irc->send_chan(
  $args->{channel}, 'NOTICE',
  $args->{channel}, $args->{message},
 );
 $res_cv->result('sent'); # return to client                                                                                   
});
AnySan->run;
  
# bot client
use AnyEvent::MPRPC;

my $channel = shift;
my $message = shift;

my $client = mprpc_client '127.0.0.1', '4423';
my $d = $client->call(
 send => {
  channel => $channel,
  message => $message,
 }
);
say $d->recv;
  

AnyEventベースなんで
もうちょっと
特徴わかりやすい
デモ作った

@dan_the_bot

Dan The Bot 特徴

こーど見ながら動かしましょう

まとめ

有り難うございました!