Skip to content

Instantly share code, notes, and snippets.

@yappo
Created November 17, 2010 04:03
Show Gist options
  • Save yappo/702960 to your computer and use it in GitHub Desktop.
Save yappo/702960 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Encode;
use Acme::Zenra;
use AnySan;
use AnySan::Provider::IRC;
my $channel = $ARGV[0] or die 'channel name is needed!';
my $appid = $ENV{YAHOO_APPID} or die 'set $ENV{YAHOO_APPID}';
my $zenra = Acme::Zenra->new( yahoo_appid => $appid );
my $irc = irc 'chat.freenode.net',
nickname => 'zenra_bot',
channels => {
$channel => {},
};
AnySan->register_listener(
zenra => {
cb => sub {
my $receive = shift;
my $message = $receive->message;
return unless $receive->attribute('command') eq 'PRIVMSG' && $message;
my $result = $zenra->zenrize( decode_utf8($message) );
$receive->send_reply('「' . $result . '」ですね。わかります') unless $message eq $result;
},
},
);
AnySan->run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment