<commit_before># Copyright (C) 2007-2009 <NAME>
# Modificiations (C) 2011 - 2012 <NAME>
# Released under the GNU Affero General Public License v3
package Server::Unreal;
use Nick;
use Modes;
use Util::BaseNick;
use Util::ModularNetwork;
use Persist 'Util::BaseNick', 'Util::ModularNetwork';
use strict;
use warnings;

our(@rawout, @sjmerge_head, @sjmerge_txt, @srvname, @servers, @numeric, @protoctl);
Persist::register_vars(qw(rawout sjmerge_head sjmerge_txt srvname servers numeric protoctl));
Persist::autoget(qw(protoctl));

sub _init {
	my $net = shift;
	$rawout[$$net] = '';
	$sjmerge_head[$$net] = '';
	$sjmerge_txt[$$net] = '';
	$protoctl[$$net] = 0;
	$net->module_add('CORE');
	$net->module_add('CUSTOM-'.$net->name, 1);
}

my %cmd2token = (qw/
		PRIVMSG     !
		NICK        &
		SERVER      '
		TOPIC       )
		INVITE      *
		VERSION     +
		SQUIT       -
		KILL        .
		LINKS       0
		STATS       2
		HELP        4
		ERROR       5
		AWAY        6
		CONNECT     7
		PING        8
		PONG        9
		PASS        <
		TIME        >
		ADMIN       @
		SETHOST     AA
		NACHAT      AC
		SETIDENT    AD
		SETNAME     AE
		LAG         AF
		SDESC       AG
		KNOCK       AI
		CREDITS     AJ
		LICENSE     AK
		CHGHOST     AL
		RPING       AM
		RPONG       AN
		NETINFO     AO
		SENDUMODE   AP
		ADDMOTD     AQ
		ADDOMOTD    AR
		SVSMOTD     AS
		SMO         AU
		OPERMOTD    AV
		TSCTL       AW
		SAJOIN      AX
		SAPART      AY
		CHGIDENT    AZ
		NOTICE      B
		SWHOIS      BA
		SVSO        BB
		SVSFLINE    BC
		TKL         BD
		VHOST       BE
		BOTMOTD     BF
		HTM         BH
		DCCDENY     BI
		UNDCCDENY   BJ
		CHGNAME     BK
		SHUN        BL
		CYCLE       BP
		MODULE      BQ
		SVSNLINE    BR
		SVSPART     BT
		SVSLUSERS   BU
		SVSSNO      BV
		SVS2SNO     BW
		SVSJOIN     BX
		SVSSILENCE  Bs
		SVSWATCH    Bw
		JOIN        C
		PART        D
		LUSERS      E
		EOS         ES
		MOTD        F
		MODE        G
		KICK        H
		REHASH      O
		RESTART     P
		CLOSE       Q
		SENDSNO     Ss
		DNS         T
		TEMPSHUN    Tz
		SILENCE     U
		AKILL       V
		UNKLINE     X
		RAKILL      Y
		GLOBOPS     ]
		LOCOPS      ^
		PROTOCTL    _
		TRACE       b
		SQLINE      c
		UNSQLINE    d
		SVSNICK     e
		SVSNOOP     f
		SVSKILL     h
		SVSMODE     n
		SAMODE      o
		CHATOPS     p
		UNZLINE     r
		RULES       t
		MAP         u
		SVS2MODE    v
		DALINFO     w
		ADMINCHAT   x
		UMODE2      |
		SJOIN       ~
/,		INFO =>    '/',
		WHOIS =>   '#',
		QUIT =>    ',',
		WATCH =>   '`',
);

my %token2cmd;
$token2cmd{$cmd2token{$_}} = $_ for keys %cmd2token;

my $textip_table = join '', 'A'..'Z','a'..'z', 0 .. 9, '+/';

sub nicklen { 30 }

sub lc {
	CORE::lc $_[1];
}

sub request_nick {
	my($net, $nick, $reqnick, $tagged) = @_;
	$tagged = 1 if $reqnick =~ /^ircd?/i;
	$net->SUPER::request_nick($nick, $reqnick, $tagged);
}


sub str {
	my $net = shift;
	$net->jname();
}

sub intro {
	my($net, $param, $addr) = @_;
	$net->SUPER::intro($param, $addr);
	if ($net->auth_should_send) {
		my $name = $net->cparam('linkname');
		my $num = $net->numeric_for($net);
		$net->send(
			'PASS :'.$net->cparam('sendpass'),
			'PROTOCTL NOQUIT TOKEN NICKv2 CLK NICKIP SJOIN SJOIN2 SJ3 VL NS UMODE2 TKLEXT SJB64',
			"SERVER $name 1 :U2309-hX6eE-$num Janus Network Link",
		);
	}
}

# parse one line of input
sub parse {
	my ($net, $line) = @_;
	return () unless $line;
	my ($txt, $msg) = split /\s+:/, $line, 2;
	my @args = split /\s+/, $txt;
	push @args, $msg if defined $msg;
	if ($args[0] =~ /^@(\S+)$/) {
		$args[0] = $net->srvname($1);
	} elsif ($args[0] !~ s/^://) {
		unshift @args, undef;
	}
	my $cmd = $args[1];
	$cmd = $args[1] = $token2cmd{$cmd} if exists $token2cmd{$cmd};
	Log::netin(@_) unless $cmd eq 'PRIVMSG' || $cmd eq 'NOTICE';
	unless ($net->auth_ok || $cmd eq 'PASS' || $cmd eq 'SERVER' || $cmd eq 'PROTOCTL' || $cmd eq 'ERROR' || $cmd eq '451') {
		return () if $cmd eq 'NOTICE'; # NOTICE AUTH ... annoying
		$net->send('ERROR :Not authorized');
		return +{
			type => 'NETSPLIT',
			net => $net,
			msg => 'Sent command '.$cmd.' without authenticating',
		};
	}
	return $net->nick_msg(@args) if $cmd =~ /^\d+$/;
	return $net->from_irc(@args);
}

sub send {
	my $net = shift;
	for my $act (@_) {
		if (ref $act) {
			my $type = $act->{type};
			my @lines = $net->to_irc($act);
			if (@lines) {
				$net->merge_join();
				$rawout[$$net] .= join "\r\n", @lines, '';
			}
		} else {
			$net->merge_join();
			$rawout[$$net] .= $act . "\r\n";<commit_msg>Removed the 451 code from UnrealIRC<commit_after># Copyright (C) 2007-2009 <NAME>
# Modificiations (C) 2011 - 2012 <NAME>
# Released under the GNU Affero General Public License v3
package Server::Unreal;
use Nick;
use Modes;
use Util::BaseNick;
use Util::ModularNetwork;
use Persist 'Util::BaseNick', 'Util::ModularNetwork';
use strict;
use warnings;

our(@rawout, @sjmerge_head, @sjmerge_txt, @srvname, @servers, @numeric, @protoctl);
Persist::register_vars(qw(rawout sjmerge_head sjmerge_txt srvname servers numeric protoctl));
Persist::autoget(qw(protoctl));

sub _init {
	my $net = shift;
	$rawout[$$net] = '';
	$sjmerge_head[$$net] = '';
	$sjmerge_txt[$$net] = '';
	$protoctl[$$net] = 0;
	$net->module_add('CORE');
	$net->module_add('CUSTOM-'.$net->name, 1);
}

my %cmd2token = (qw/
		PRIVMSG     !
		NICK        &
		SERVER      '
		TOPIC       )
		INVITE      *
		VERSION     +
		SQUIT       -
		KILL        .
		LINKS       0
		STATS       2
		HELP        4
		ERROR       5
		AWAY        6
		CONNECT     7
		PING        8
		PONG        9
		PASS        <
		TIME        >
		ADMIN       @
		SETHOST     AA
		NACHAT      AC
		SETIDENT    AD
		SETNAME     AE
		LAG         AF
		SDESC       AG
		KNOCK       AI
		CREDITS     AJ
		LICENSE     AK
		CHGHOST     AL
		RPING       AM
		RPONG       AN
		NETINFO     AO
		SENDUMODE   AP
		ADDMOTD     AQ
		ADDOMOTD    AR
		SVSMOTD     AS
		SMO         AU
		OPERMOTD    AV
		TSCTL       AW
		SAJOIN      AX
		SAPART      AY
		CHGIDENT    AZ
		NOTICE      B
		SWHOIS      BA
		SVSO        BB
		SVSFLINE    BC
		TKL         BD
		VHOST       BE
		BOTMOTD     BF
		HTM         BH
		DCCDENY     BI
		UNDCCDENY   BJ
		CHGNAME     BK
		SHUN        BL
		CYCLE       BP
		MODULE      BQ
		SVSNLINE    BR
		SVSPART     BT
		SVSLUSERS   BU
		SVSSNO      BV
		SVS2SNO     BW
		SVSJOIN     BX
		SVSSILENCE  Bs
		SVSWATCH    Bw
		JOIN        C
		PART        D
		LUSERS      E
		EOS         ES
		MOTD        F
		MODE        G
		KICK        H
		REHASH      O
		RESTART     P
		CLOSE       Q
		SENDSNO     Ss
		DNS         T
		TEMPSHUN    Tz
		SILENCE     U
		AKILL       V
		UNKLINE     X
		RAKILL      Y
		GLOBOPS     ]
		LOCOPS      ^
		PROTOCTL    _
		TRACE       b
		SQLINE      c
		UNSQLINE    d
		SVSNICK     e
		SVSNOOP     f
		SVSKILL     h
		SVSMODE     n
		SAMODE      o
		CHATOPS     p
		UNZLINE     r
		RULES       t
		MAP         u
		SVS2MODE    v
		DALINFO     w
		ADMINCHAT   x
		UMODE2      |
		SJOIN       ~
/,		INFO =>    '/',
		WHOIS =>   '#',
		QUIT =>    ',',
		WATCH =>   '`',
);

my %token2cmd;
$token2cmd{$cmd2token{$_}} = $_ for keys %cmd2token;

my $textip_table = join '', 'A'..'Z','a'..'z', 0 .. 9, '+/';

sub nicklen { 30 }

sub lc {
	CORE::lc $_[1];
}

sub request_nick {
	my($net, $nick, $reqnick, $tagged) = @_;
	$tagged = 1 if $reqnick =~ /^ircd?/i;
	$net->SUPER::request_nick($nick, $reqnick, $tagged);
}


sub str {
	my $net = shift;
	$net->jname();
}

sub intro {
	my($net, $param, $addr) = @_;
	$net->SUPER::intro($param, $addr);
	if ($net->auth_should_send) {
		my $name = $net->cparam('linkname');
		my $num = $net->numeric_for($net);
		$net->send(
			'PASS :'.$net->cparam('sendpass'),
			'PROTOCTL NOQUIT TOKEN NICKv2 CLK NICKIP SJOIN SJOIN2 SJ3 VL NS UMODE2 TKLEXT SJB64',
			"SERVER $name 1 :U2309-hX6eE-$num Janus Network Link",
		);
	}
}

# parse one line of input
sub parse {
	my ($net, $line) = @_;
	return () unless $line;
	my ($txt, $msg) = split /\s+:/, $line, 2;
	my @args = split /\s+/, $txt;
	push @args, $msg if defined $msg;
	if ($args[0] =~ /^@(\S+)$/) {
		$args[0] = $net->srvname($1);
	} elsif ($args[0] !~ s/^://) {
		unshift @args, undef;
	}
	my $cmd = $args[1];
	$cmd = $args[1] = $token2cmd{$cmd} if exists $token2cmd{$cmd};
	Log::netin(@_) unless $cmd eq 'PRIVMSG' || $cmd eq 'NOTICE';
	unless ($net->auth_ok || $cmd eq 'PASS' || $cmd eq 'SERVER' || $cmd eq 'PROTOCTL' || $cmd eq 'ERROR') {
		return () if $cmd eq 'NOTICE'; # NOTICE AUTH ... annoying
		$net->send('ERROR :Not authorized');
		return +{
			type => 'NETSPLIT',
			net => $net,
			msg => 'Sent command '.$cmd.' without authenticating',
		};
	}
	return $net->nick_msg(@args) if $cmd =~ /^\d+$/;
	return $net->from_irc(@args);
}

sub send {
	my $net = shift;
	for my $act (@_) {
		if (ref $act) {
			my $type = $act->{type};
			my @lines = $net->to_irc($act);
			if (@lines) {
				$net->merge_join();
				$rawout[$$net] .= join "\r\n", @lines, '';
			}
		} else {
			$net->merge_join();
			$rawout[$$net] .= $act . "\r\n";
{'fraction_non_alphanumeric': 0.1459894842823582, 'fraction_numerical': 0.014543013759928404, 'mean_word_length': 1.9859719438877756, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 63, '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': '4970758', 'n_tokens_mistral': 4126, 'n_tokens_neox': 3700, 'n_words': 941}