めんどくさいの箇条書き。
- YAPC::Asia 2009 前夜祭 出張 Yokohama.pm の参加希望者がもうすぐ100人!
- ATND で募集してるので、そのページを再読み込みしまくり
- それ AnyEvent::Feed と AnyEvent::IRC::Client でほぼリアルタイムに #yokohama.pm に流せばいいんじゃね?
- 作り始める
- 楽しくなってくる
- できたー
- #yokohama.pm に投入
- 既に100人定員に達している
- いまさらすぐるw
というネタ。
ソース。某 typostar さんによれば Superfeedr 使うと polling しなくていいらしいお!
#!/usr/bin/perl use strict; use warnings; use AnyEvent::Feed; use AnyEvent::IRC::Client; use AnyEvent; use Encode; my $channel = "#yokohama.pm"; my $cv = AnyEvent->condvar; my $pc = AnyEvent::IRC::Client->new; $pc->reg_cb( connect => sub { my ( $pc, $err ) = @_; if ( defined $err ) { print "Couldn't connect to server: $err\n"; } }, registered => sub { my ($self) = @_; print "registered!\n"; $pc->enable_ping(60); }, disconnect => sub { print "disconnected: $_[1]!\n"; } ); $pc->send_srv( "JOIN", $channel ); $pc->send_chan( $channel, "NOTICE", $channel, "hi" ); $pc->connect( "irc.freenode.net", 6667, { nick => 'atnd_bot', user => 'atnd_bot', real => 'ATND bot' } ); my $feed = AnyEvent::Feed->new( url => "http://atnd.org/events/show/1304.rss", interval => 60 * 1, on_fetch => sub { my ( $fee, $ent, $feed, $er ) = @_; if ( defined $er ) { warn "ERROR: $er\n"; $cv->send; return; } my @msg; for (@$ent) { my $str = $_->[1]->content->body; $str =~ s/\n//gm; $str =~ s/\s+/ /gm; $str = encode( 'utf8', $_->[1]->title . $str ); print "$str\n"; $pc->send_chan( $channel, "NOTICE", $channel, $str ); } } ); $cv->recv;