File: quiet.pl

package info (click to toggle)
sirc 2.211-9.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, squeeze
  • size: 476 kB
  • ctags: 420
  • sloc: perl: 5,330; ansic: 1,200; sh: 855; makefile: 78
file content (101 lines) | stat: -rw-r--r-- 2,547 bytes parent folder | download
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
###############################################################################
# quiet.pl filters join/leave/kick/signoff and changenick. A join can
# be seen only when the person says something in public. A leave can
# be seen only if the join was seen. A kick can be seen only if the
# join was seen, etc. Use the /quiet #channel command to add a channel
# in the list of filtered channels.

$add_ons.="+quiet.pl" if $add_ons !~ /quiet/;

sub cmd_quiet {
    &getarg;
    if($newarg) {
	local($c) = $newarg; $c =~ tr/[A-Z]/[a-z]/;
	unless ($c =~ /^[\#\&\+]/) { $c='#'.$c; }
	if($quiet_channel{$c}) {
	    delete $quiet_channel{$c};
	    &tell("*\cbq\cb* Removing $c from the list of filtered channels\n");
	} else {
	    $quiet_channel{$c} = 1;
	    &tell("*\cbq\cb* Adding $c to the list of filtered channels\n");
	}
    } else {
	local($s) = "*\cbq\cb* Quiet channels :";
	foreach $c ( keys %quiet_channel ) {
	    $s .= " ";
	    $s .= $c;
	}
	&tell($s);
    }
}

&addcmd("quiet");

sub hook_q_join {
    local($c) = $_[0]; $c =~ tr/[A-Z]/[a-z]/;
    if($quiet_channel{$c}) {
	$have_joined{$c}{$who} = "$user\@$host";
	$silent = 1;
    }
}

sub hook_q_leave {
    local($c) = $_[0]; $c =~ tr/[A-Z]/[a-z]/;
    if($have_joined{$c}{$who}) {
	delete $have_joined{$c}{$who};
	$silent = 1;
    }
}

sub hook_q_kick {
    local($c) = $_[1]; $c =~ tr/[A-Z]/[a-z]/;
    if($have_joined{$c}{$_[0]}) {
	delete $have_joined{$c}{$_[0]};
	$silent = 1;
    }
}

sub hook_q_nick {
    foreach $c ( keys %quiet_channel ) {
	if($have_joined{$c}{$who}) {
	    &tell("*\cbq\cb* $who ($have_joined{$c}{$who}) is in channel $c");
	    delete $have_joined{$c}{$who};
	}
    }
}

sub hook_q_public {
    local($c) = $_[0]; $c =~ tr/[A-Z]/[a-z]/;
    if($have_joined{$c}{$who}) {
	&tell("*\cbq\cb* $who ($have_joined{$c}{$who}) is in channel $c");
	delete $have_joined{$c}{$who};
    }
}

sub hook_q_signoff {
    foreach $c ( keys %quiet_channel ) {
	delete $have_joined{$c}{$who};
    }
}

sub hook_q_mode {
    local($c) = $_[0]; $c =~ tr/[A-Z]/[a-z]/;
    if($quiet_channel{$c}) {
	if($args =~ /^[\+\-][lsnmk]/) {
	    $silent = 1; 
	}
    }
}

&addhook("join", "q_join");
&addhook("leave", "q_leave");
&addhook("kick", "q_kick");
&addhook("nick", "q_nick");
&addhook("public", "q_public");
&addhook("signoff", "q_signoff");
&addhook("mode", q_mode);

&addhelp("quiet", "Usage: \cbQUIET\cb [<channel>]
Without argument, shows the list of quiet channels, with an argument adds the channel or removes it.");

&print("*\cbq\cb* \cbTHX-1138\cb's quiet.pl loaded");