aboutsummaryrefslogtreecommitdiffstats
path: root/feature-tests/rejoin-unban.pl
blob: ea4322067438c49a9f174661447c30ff35907def (plain) (blame)
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
use strict;
use warnings;

use Data::Dumper;

# not sure of hte original source author, but probably based on
# autorejoin.pl: http://scripts.irssi.org/html/autorejoin.pl.html

our $VERSION = '0.1';
our %IRSSI = (
              authors     => 'shabble, dunno original source',
              contact     => 'shabble+irssi@metavore.org',
              name        => '',
              description => '',
              license     => 'GPLv2',
              updated     => '$DATE'
             );


use Irssi;
use Irssi::Irc;


sub event_rejoin_kick  {
    my ($server, $data) = @_;
    my ($channel, $nick) = split(/ +/, $data);

    return if ($server->{nick} ne $nick);

    my $chanrec = $server->channel_find($channel);
    my $password = $chanrec->{key} if ($chanrec);

    Irssi::print "Rejoining $channel...";

    $server->send_raw("JOIN $channel $password");
}

sub event_rejoin_unban {
    my ($server, $data, $nick, $address) = @_;
    my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;

    if ($text =~ m/(\w+) has been unbanned from (#?\w+)/) {
        my ($nick, $channel) = ($1, $2);
        my $chanrec = $server->channel_find($channel);
        my $password = $chanrec->{key} if ($chanrec);

        Irssi::print "Rejoining $channel...";
        $server->command("JOIN $channel $password");
    }
}

sub event_unban {
    my ($server, $data) = @_;
    my ($nick, $channel) = split(/ +/, $data);

    Irssi::print "Attempting unban on $channel...";
    $server->send_raw("PRIVMSG ChanServ unban $channel");
}

sub sig_msg_kick {
    my ($server, $channel, $victim, $kicker, $addr, $reason) = @_;

}

sub sig_msg_notice {
    my ($server, $msg, $nick, $addr, $target) = @_;

}

sub sig_event_joinfail_banned {

}

sub init {

    Irssi::signal_add('message kick',   'sig_msg_kick');
    Irssi::signal_add('message notice', 'sig_msg_notice');
    Irssi::signal_add('event 474',      'sig_event_joinfail_banned');

}

init();