home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.madoka.org
/
2014.12.ftp.madoka.org.tar
/
ftp.madoka.org
/
pub
/
plum
/
1.x
/
plum10b8.lzh
/
plum10b8
/
main.plm
< prev
next >
Wrap
Text File
|
1997-06-25
|
8KB
|
228 lines
package main;
$_ = 'main';
sub client_open {
local($clientno) = @_;
local($serverno) = $'server[$'userno[$clientno]];
if ($'avail[$serverno]) {
if ($'nick[$clientno] ne $'nick[$serverno]) {
&'c_print($clientno, &'user($clientno), 'NICK', $'nick[$serverno]);
}
}
&'c_print($clientno, $'HOSTNAME, '001', $'nick[$clientno], "Welcome to the Internet Relay Network $'nick[$clientno]");
&'c_print($clientno, $'HOSTNAME, '002', $'nick[$clientno], $msg002[$'userno[$clientno]] || '');
&'c_print($clientno, $'HOSTNAME, '003', $'nick[$clientno], $msg003[$'userno[$clientno]] || '');
&'c_print($clientno, $'HOSTNAME, '004', $'nick[$clientno], $msg004[$'userno[$clientno]] || '');
&joinchannel($clientno);
}
sub server_open {
local($serverno) = @_;
$msg002[$'userno[$serverno]] = '';
$msg003[$'userno[$serverno]] = '';
$msg004[$'userno[$serverno]] = '';
$chanlist[$'userno[$serverno]] = $;;
foreach $clientno (&'array($'clientlist)) {
next unless $'userno[$clientno] == $'userno[$serverno];
next unless $'avail[$clientno];
next unless $'nick[$clientno] ne $'nick[$serverno];
&'c_print($clientno, &'user($clientno), 'NICK', $'nick[$serverno]);
}
}
sub cs_privmsg {
local($clientno, $prefix, $cmd, $chan, $msg) = @_;
foreach $cno (&'array($'clientlist)) {
next unless $clientno != $cno;
next unless $'userno[$clientno] == $'userno[$cno];
next unless $'avail[$cno];
&'c_print($cno, &'user($cno), $cmd, $chan, $msg);
}
return ($prefix, $cmd, $chan, $msg);
}
sub cs_quit {
local($clientno, $prefix, $cmd, $msg) = @_;
$msg = $'nick[$clientno] unless $msg;
&'c_print($clientno, '', 'ERROR', "Closing Link: $'nick[$clientno]" . "[$'host[$clientno]] ($msg)");
&'c_close($clientno);
return ();
}
sub cp_nick {
local($clientno, $prefix, $cmd, $newnick) = @_;
local($nick, $user, $host) = &'prefix($prefix);
if ($nick eq $'nick[$clientno]) {
$'nick[$clientno] = $newnick;
}
return ($prefix, $cmd, $newnick);
}
sub ss_ping {
local($serverno, $prefix, $cmd, @params) = @_;
&'s_print($serverno, '', 'PONG', @params);
return ($prefix, $cmd, @params);
}
sub ss_nick {
local($serverno, $prefix, $cmd, $newnick) = @_;
local($nick, $user, $host) = &'prefix($prefix);
local($userno) = $'userno[$serverno];
if ($nick eq $'nick[$serverno]) {
$'nick[$serverno] = $newnick;
$'nickname[$userno] = $newnick;
}
foreach $chan (&'array($'chanlist[$userno])) {
$'nameslist{$userno, $chan} = &'change($'nameslist{$userno, $chan} || $;, $nick, $newnick, "+$nick", "+$newnick", "\@$nick", "\@$newnick");
}
return ($prefix, $cmd, $newnick);
}
sub ss_join {
local($serverno, $prefix, $cmd, $chan) = @_;
local($nick, $user, $host) = &'prefix($prefix);
local($userno) = $'userno[$serverno];
if ($nick eq $'nick[$serverno]) {
$chanlist[$userno] = &'add($chanlist[$userno] || $;, $chan);
$'nameslist{$userno, $chan} = $;
} else {
$'nameslist{$userno, $chan} = &'add($'nameslist{$userno, $chan} || $;, $nick);
}
return ($prefix, $cmd, $chan);
}
sub ss_part {
local($serverno, $prefix, $cmd, $chan) = @_;
local($nick, $user, $host) = &'prefix($prefix);
local($userno) = $'userno[$serverno];
if ($nick eq $'nick[$serverno]) {
$chanlist[$userno] = &'remove($'chanlist[$userno] || $;, $chan);
delete $'nameslist{$userno, $chan};
} else {
$'nameslist{$userno, $chan} = &'remove($'nameslist{$userno, $chan} || $;, $nick, "+$nick", "\@$nick");
}
return ($prefix, $cmd, $chan);
}
sub ss_kick {
local($serverno, $prefix, $cmd, $chan, $who, $msg) = @_;
local($nick, $user, $host) = &'prefix($prefix);
local($userno) = $'userno[$serverno];
if ($who eq $'nick[$serverno]) {
$chanlist[$userno] = &'remove($chanlist[$userno] || $;, $chan);
delete $'nameslist{$userno, $chan};
} else {
$'nameslist{$userno, $chan} = &'remove($'nameslist{$userno, $chan} || $;, $who, "+$who", "\@$who");
}
return ($prefix, $cmd, $chan, $who, $msg);
}
sub ss_quit {
local($serverno, $prefix, $cmd, $msg) = @_;
local($nick, $user, $host) = &'prefix($prefix);
local($userno) = $'userno[$serverno];
foreach $chan (&'array($chanlist[$userno])) {
$'nameslist{$userno, $chan} = &'remove($'nameslist{$userno, $chan} || $;, $nick, "+$nick", "\@$nick");
}
return ($prefix, $cmd, $msg);
}
sub ss_mode {
local($serverno, $prefix, $cmd, @params) = @_;
local($chan, $mode, @modes) = @params;
local($userno, $flag, $name);
$userno = $'userno[$serverno];
foreach $char (split(//, $mode)) {
if ($char eq '+' || $char eq '-') {
$flag = $char;
} elsif ($char eq 'b') {
shift(@modes);
} elsif ($char eq 'i') {
} elsif ($char eq 'k') {
if ($flag eq '+') {
$'key{$userno, $chan} = shift(@modes);
} elsif ($flag eq '-') {
$'key{$userno, $chan} = '';
}
} elsif ($char eq 'l') {
if ($flag eq '+') {
$'limit{$userno, $chan} = shift(@modes);
} elsif ($flag eq '-') {
$'limit{$userno, $chan} = '';
}
} elsif ($char eq 'o') {
$name = shift(@modes);
if ($flag eq '+') {
$'nameslist{$userno, $chan} = &'change($'nameslist{$userno, $chan}, $name, "\@$name", "+$name", "\@$name");
} elsif ($flag eq '-') {
$'nameslist{$userno, $chan} = &'change($'nameslist{$userno, $chan}, "\@$name", $name);
}
} elsif ($char eq 'v') {
$name = shift(@modes);
if ($flag eq '+') {
$'nameslist{$userno, $chan} = &'change($'nameslist{$userno, $chan}, $name, "+$name");
} elsif ($flag eq '-') {
$'nameslist{$userno, $chan} = &'change($'nameslist{$userno, $chan}, "+$name", $name);
}
}
}
return ($prefix, $cmd, @params);
}
sub ss_topic {
local($serverno, $prefix, $cmd, $chan, $topic) = @_;
$'topic{$'userno[$serverno], $chan} = $topic;
return ($prefix, $cmd, $chan, $topic);
}
sub ss_002 {
local($serverno, $prefix, $cmd, $nick, $msg) = @_;
$msg002[$'userno[$serverno]] = $msg;
return ($prefix, $cmd, $nick, $msg);
}
sub ss_003 {
local($serverno, $prefix, $cmd, $nick, $msg) = @_;
$msg003[$'userno[$serverno]] = $msg;
return ($prefix, $cmd, $nick, $msg);
}
sub ss_004 {
local($serverno, $prefix, $cmd, $nick, $msg) = @_;
$msg004[$'userno[$serverno]] = $msg;
return ($prefix, $cmd, $nick, $msg);
}
sub ss_332 {
local($serverno, $prefix, $cmd, $nick, $chan, $topic) = @_;
$'topic{$'userno[$serverno], $chan} = $topic;
return ($prefix, $cmd, $nick, $chan, $topic);
}
sub ss_353 {
local($serverno, $prefix, $cmd, @params) = @_;
local($userno) = $'userno[$serverno];
$'nameslist{$userno, $params[2]} = &'add($'nameslist{$userno, $params[2]} || $;, reverse(split(/\s+/, $params[3])));
return ($prefix, $cmd, @params);
}
sub joinchannel {
local($clientno) = @_;
local($userno) = $'userno[$serverno];
foreach $channel (&'array($chanlist[$userno])) {
&'c_print($clientno, &'user($clientno), 'JOIN', $channel);
&'c_print($clientno, &'user($clientno), '332', $'nick[$clientno], $channel, $'topic{$userno, $channel}) if $'topic{$userno, $channel};
&'c_print($clientno, $HOSTNAME, '353', $'nick[$clientno], '=', $channel, join(' ', &'rarray($'nameslist{$userno, $channel})));
&'c_print($clientno, $HOSTNAME, '366', $'nick[$clientno], $channel, 'End of /NAMES list.');
}
}
sub partchannel {
local($clientno) = @_;
foreach $channel (&'array($'chanlist[$'userno[$clientno]])) {
&'c_print($clientno, &'user($clientno), 'PART', $channel);
}
}