<commit_before>use strict;
use bsdconv;

use vars qw($VERSION %IRSSI);
$VERSION = '2009060600';
%IRSSI = (
	authors		=> 'Buganini',
	contact		=> '<EMAIL>',
	name		=> 'bsdconv',
	description	=> 'bsdconv conversion',
	license		=> 'BSD',
	url		=> 'http://github.com/buganini/bsdconv',
	modules		=> 'bsdconv',
);

my $bsdconv_ignore = 0;

sub event_send_text () {
	if($bsdconv_ignore){
		return;
	}
	my ($line, $server_rec, $wi_item_rec) = @_;
	my $conversion = Irssi::settings_get_str('bsdconv');
	$conversion =~ s/^\s+|\s+$//g;
	my $h = bsdconv::create($conversion);
	if(!defined($h)){
		Irssi:print(bsdconv::error());
		return;
	}
	my $line=bsdconv::conv($h,$line);
	bsdconv::destroy($h);
	$bsdconv_ignore = 1;
	Irssi::signal_emit('send text', $line,  $server_rec, $wi_item_rec);
	Irssi::signal_stop();
	$bsdconv_ignore = 0;
}

Irssi::signal_add_first('send text', "event_send_text");
Irssi::settings_add_str("misc", "bsdconv", "utf-8:utf-8");
<commit_msg>improve irssi script<commit_after>use strict;
use bsdconv;

use vars qw($VERSION %IRSSI);
$VERSION = '2009060600';
%IRSSI = (
	authors		=> 'Buganini',
	contact		=> '<EMAIL>',
	name		=> 'bsdconv',
	description	=> 'bsdconv conversion',
	license		=> 'BSD',
	url		=> 'http://github.com/buganini/bsdconv',
	modules		=> 'bsdconv',
);

my $bsdconv_ignore = 0;

sub on_recv () {
	if($bsdconv_ignore){
		return;
	}
	my ($server, $line, $nick, $address) = @_;
	my $conversion = Irssi::settings_get_str('bsdconv_in');
	$conversion =~ s/^\s+|\s+$//g;
	my $h = bsdconv::create($conversion);
	if($conversion=='') return;
	if(!defined($h)){
		Irssi:print(bsdconv::error());
		return;
	}
	my $line=bsdconv::conv($h,$line);
	bsdconv::destroy($h);
	$bsdconv_ignore = 1;
	Irssi::signal_emit('event privmsg', ($server, $line, $nick, $address));
	$bsdconv_ignore = 0;
	Irssi::signal_stop();
}

sub on_topic () {
	if($bsdconv_ignore){
		return;
	}
	my ($server_rec) = @_;
	my $conversion = Irssi::settings_get_str('bsdconv_in');
	$conversion =~ s/^\s+|\s+$//g;
	if($conversion=='') return;
	my $h = bsdconv::create($conversion);
	if(!defined($h)){
		Irssi:print(bsdconv::error());
		return;
	}
	my $line=bsdconv::conv($h,$server_rec->{topic});
	$server_rec->{topic}=$line;
	bsdconv::destroy($h);
	$bsdconv_ignore = 1;
	Irssi::signal_emit('channel topic changed', $server_rec);
	$bsdconv_ignore = 0;
	Irssi::signal_stop();
}

sub bsdconv_out () {
	if($bsdconv_ignore){
		return;
	}
	my ($line, $server_rec, $wi_item_rec) = @_;
	my $conversion = Irssi::settings_get_str('bsdconv_out');
	$conversion =~ s/^\s+|\s+$//g;
	if($conversion=='') return;
	my $h = bsdconv::create($conversion);
	if(!defined($h)){
		Irssi:print(bsdconv::error());
		return;
	}
	my $line=bsdconv::conv($h,$line);
	bsdconv::destroy($h);
	$bsdconv_ignore = 1;
	Irssi::signal_emit('send text', $line,  $server_rec, $wi_item_rec);
	$bsdconv_ignore = 0;
	Irssi::signal_stop();
}

Irssi::signal_add('event privmsg', "on_recv");
#Irssi::signal_add('channel topic changed', "on_topic");
Irssi::signal_add_first('send text', "bsdconv_out");
Irssi::settings_add_str("misc", "bsdconv_in", "utf-8,ascii:utf-8,ascii");
Irssi::settings_add_str("misc", "bsdconv_out", "utf-8,ascii:utf-8,ascii");

{'fraction_non_alphanumeric': 0.21695447409733123, 'fraction_numerical': 0.01130298273155416, 'mean_word_length': 6.095768374164811, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7434171', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1319, 'n_words': 216}