]>
jfr.im git - irc/SurrealServices/srsv.git/blob - branches/erry-devel/modules/connectserv.pm
1 # This file is part of SurrealServices.
3 # SurrealServices is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # SurrealServices is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with SurrealServices; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 use SrSv
::IRCd
::State
'initial_synced';
22 use SrSv
::IRCd
::Event
'addhandler';
24 use SrSv
::Conf2Consts
qw(main);
28 use SrSv
::Process
::InParent
qw(
29 ev_nickconn ev_nickchange ev_quit ev_kill ev_umode ev_connect message
36 my $csnick = 'ConnectServ';
38 agent_connect
($csnick, 'services', undef, '+pqzBHS', 'Connection Monitor');
39 agent_join
($csnick, main_conf_diag
);
40 ircd
::setmode
($csnick, main_conf_diag
, '+o', $csnick);
42 addhandler
('NICKCONN', undef, undef, 'connectserv::ev_nickconn', 1);
44 my ($nick, $ident, $host, $server, $gecos) = @_[0,3,4,5,9];
46 $userlist{lc $nick} = [$ident, $host, $gecos, $server];
48 return unless initial_synced
();
49 message
("\00304\002SIGNED ON\002 user: \002$nick\002 ($ident\@$host - $gecos\017\00304) at $server");
52 addhandler
('NICKCHANGE', undef, undef, 'connectserv::ev_nickchange', 1);
56 unless(lc($new) eq lc($old)) {
57 $userlist{lc $new} = $userlist{lc $old};
58 delete($userlist{lc $old});
60 ($ident, $host) = @{$userlist{lc $new}} if (defined($userlist{lc $new}));
61 message
("\00307\002NICK CHANGE\002 user: \002$old\002 ($ident\@$host) changed their nick to \002$new\002");
64 addhandler
('CHGIDENT', undef, undef, 'connectserv::ev_identchange', 1);
66 my (undef, $nick, $ident) = @_;
68 my ($oldident, $host, $gecos, $server) = @{$userlist{lc $nick}} if (defined($userlist{lc $nick}));
69 $userlist{lc $nick} = [$ident, $host, $gecos, $server];
71 message
("\00310\002IDENT CHANGE\002 user: \002$nick\002 ($oldident\@$host) changed their virtual ident to \002$ident\002");
74 addhandler
('QUIT', undef, undef, 'connectserv::ev_quit', 1);
76 my ($nick, $reason) = @_;
77 my ($ident, $host, $gecos, $server);
78 if(defined($userlist{lc $nick})) {
79 ($ident, $host, $gecos, $server) = @{$userlist{lc $nick}};
80 delete($userlist{lc $nick});
82 return unless initial_synced
();
83 message
("\00303\002SIGNED OFF\002 user: \002$nick\002 ($ident\@$host - $gecos\017\00303) at $server - $reason");
86 addhandler
('KILL', undef, undef, 'connectserv::ev_kill', 1);
88 my ($src, $target, $reason) = @_[0,1,3];
89 my ($ident, $host, $gecos, $server);
90 if(defined($userlist{lc $target})) {
91 ($ident, $host, $gecos, $server) = @{$userlist{lc $target}};
92 delete($userlist{lc $target});
94 message
("\00302\002GLOBAL KILL\002 user: \002$target\002 ($ident\@$host) killed by \002$src\002 - $reason");
97 addhandler
('UMODE', undef, undef, 'connectserv::ev_umode', 1);
99 my ($nick, $modes) = @_;
100 my @modes = split(//, $modes);
102 foreach my $m (@modes) {
103 $sign = 1 if $m eq '+';
104 $sign = 0 if $m eq '-';
107 $label = 'Global Operator' if $m eq 'o';
108 $label = 'Services Administrator' if $m eq 'a';
109 $label = 'Server Administrator' if $m eq 'A';
110 $label = 'Network Administrator' if $m eq 'N';
111 $label = 'Co Administrator' if $m eq 'C';
112 $label = 'Bot' if $m eq 'B';
115 message
("\00306\002$nick\002 is ".($sign ? 'now' : 'no longer')." a \002$label\002 (".($sign ? '+' : '-')."$m)");
121 ircd
::privmsg
($csnick, main_conf_diag
, @_);
122 write_log
('diag', '<'.$csnick.'>', @_);