-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrwho.pl
139 lines (125 loc) · 4.13 KB
/
rwho.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# rwho.pl
#
# !IMPORTANT! - This script is BROKEN and is only in the repository for
# historical reasons only! Do not use this.
#
# Credits:
#
# coekie - [email protected]
# mauke - unknown
#
# This program is free software, you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PERTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# SYNTAX:
# /rwho
#
# Settings:
#
# /set rwho_server - server to /who on. Wildcard is supported (*)
# /set rwho_min_Users - If the number of users using the same realname is less than this value, don't bother printing.
#
# ChangeLog:
# 2005022301 - Svante Kvarnstrom <[email protected]>
# Made spaces into "?", colour codes, bold, italics,
# underline into "<c>1,0", "<b>", "<i>", "<u>" when
# listing the /rwho output. Will probably make an
# option to make these "*" and "?" later.
#
# 2004070601 - Svante Kvarnstrom <[email protected]>
# Initial release.
#
use strict;
use vars qw($VERSION %IRSSI);
use Irssi
qw(settings_add_str settings_get_str signal_add command_bind printformat theme_register);
$VERSION = '2004070601';
%IRSSI = (
authors => 'Svarre',
# contact => '[email protected]',
contact => '[email protected]',
name => 'rwho.pl',
description =>
'Lists commonly used realnames on the server/network. Tested on ircu. Oper privs are needed for this script to be efficient',
);
my %count;
my $rwho;
sub cmd_rwho {
my ( $data, $server, $witem ) = @_;
# Another /Rwho is already in progress
if ($rwho) {
printformat( MSGLEVEL_CLIENTCRAP, 'rwho_warn',
'Another /RWHO is already in progress! Ignoring!' );
return;
}
$server->redirect_event(
"who", 1, "", 0, undef,
{
"event 352" => "redir rwhoitem",
"event 315" => "redir rwhoitemend",
"" => "event empty"
}
);
$server->send_raw(
"WHO " . Irssi::settings_get_str('rwho_server') . " sx" );
$rwho = 1;
printformat( MSGLEVEL_CLIENTCRAP, 'rwho_start',
Irssi::settings_get_str("rwho_server") );
}
sub event_rwhoitem {
my ( $server, $data ) = @_;
if ( $data =~ /(?:\S+\s+){8}(.*)$/ ) {
my $item = $1;
$item =~ s/\002/<b>/g;
$item =~ s/\022/<i>/g;
$item =~ s/\037/<u>/g;
$item =~ s/\003([0-9]+)(,[0-9+])?/<c>\1,\2/g;
$item =~ s/\s/?/g;
$count{"$item"}++;
}
}
# something is wrong in the following sub
sub event_rwhoitemend {
foreach my $key ( keys %count ) {
if ( $count{$key} >= Irssi::settings_get_str('rwho_min_users') ) {
# $key =~ s/\002/<b>/g;
# $key =~ s/\022/<i>/g;
# $key =~ s/\037/<u>/g;
# $key =~ s/\003([0-9]+)(,[0-9+])?/<c>\1,\2/g;
printformat( MSGLEVEL_CLIENTCRAP, 'rwho_item',
"$count{\"$key\"}", "$key"
);
$count{"$key"} = 0;
}
$count{"$key"} = 0;
}
$rwho = 0;
printformat( MSGLEVEL_CLIENTCRAP, 'rwho_end' );
}
command_bind( 'rwho', 'cmd_rwho' );
signal_add( 'redir rwhoitem', 'event_rwhoitem' );
signal_add( 'redir rwhoitemend', 'event_rwhoitemend' );
settings_add_str( 'rwho', 'rwho_min_users', '5' );
settings_add_str( 'rwho', 'rwho_server', 'lidingo*' );
theme_register(
[
'rwho_start', '%R>>%n /RWHO on $0',
'rwho_item', '%R>>%n $[-4]0: $1',
'rwho_end', '%R>>%n End of /RWHO',
'rwho_warn', '%R>> WARNING:%n $0',
'rwho_loaded', '%R>>%n %_Scriptinfo:%_ Loaded $0 version $1 by $2.',
]
);
printformat( MSGLEVEL_CLIENTCRAP, 'rwho_loaded', $IRSSI{name}, $VERSION,
$IRSSI{authors} );