Skip to content

Instantly share code, notes, and snippets.

@konishika
Last active December 31, 2015 00:19
Show Gist options
  • Save konishika/7906972 to your computer and use it in GitHub Desktop.
Save konishika/7906972 to your computer and use it in GitHub Desktop.
AnySanを往年のJISなircで利用しようかと思ったときに、毎回使う側でjisに変換するのが面倒になった時に、つかうモンキーパッチ
{
no warnings 'redefine';
use Encode qw/from_to/;
*AnySan::Provider::IRC::send_message = sub {
my ( $self, $message, %args ) = @_;
from_to( $message, 'UTF-8', 'jis' );
my $channel = $args{channel};
from_to( $channel, 'UTF-8', 'jis' );
$self->_run(
sub {
my $type = $args{privmsg} ? 'PRIVMSG' : 'NOTICE';
$self->{client}->send_chan( $channel, $type, $channel, $message, );
}
);
};
*AnySan::Provider::IRC::join_channel = sub {
my ( $self, $channel, $key ) = @_;
from_to( $channel, 'UTF-8', 'jis' );
$self->{client}->send_srv( JOIN => $channel, $key );
};
*AnySan::Provider::IRC::leave_channel = sub {
my($self, $channel) = @_;
from_to( $channel, 'UTF-8', 'jis' );
$self->{client}->send_srv( PART => $channel );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment