summaryrefslogtreecommitdiffstats
path: root/scripts/smartfilter.pl
blob: f82ebb152703bc938060305de25b8c9eb6e9b6c4 (plain)
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
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);

$VERSION = "0.1";

%IRSSI = (
    authors     => 'Christian Brassat',
    contact     => 'crshd@mail.com',
    name        => 'smartfilter.pl',
    description => 'This script hides join/part messages.',
    license     => 'BSD',
    url         => 'http://crshd.github.io',
    changed     => '2012-10-02',
);

our $lastmsg = {};

sub smartfilter {
    my ($channel, $nick, $address, $reason) = @_;
    if ($lastmsg->{$nick} <= time() - Irssi::settings_get_int('smartfilter_delay')) {
        Irssi::signal_stop();
    }
};

sub log {
    my ($server, $msg, $nick, $address, $target) = @_;
    $lastmsg->{$nick} = time();
}

Irssi::signal_add('message public', 'log');
Irssi::signal_add('message join', 'smartfilter');
Irssi::signal_add('message part', 'smartfilter');
Irssi::signal_add('message quit', 'smartfilter');

Irssi::settings_add_int('smartfilter', 'smartfilter_delay', 300);