~ubuntu-branches/ubuntu/hardy/irssi/hardy-updates

« back to all changes in this revision

Viewing changes to scripts/autorejoin.pl

  • Committer: Bazaar Package Importer
  • Author(s): David Pashley
  • Date: 2005-12-10 21:25:51 UTC
  • Revision ID: james.westby@ubuntu.com-20051210212551-5qwm108g7inyu2f2
Tags: upstream-0.8.10
ImportĀ upstreamĀ versionĀ 0.8.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# automatically rejoin to channel after kicked
 
2
 
 
3
# /SET autorejoin_channels #channel1 #channel2 ...
 
4
 
 
5
# NOTE: I personally don't like this feature, in most channels I'm in it
 
6
# will just result as ban. You've probably misunderstood the idea of /KICK
 
7
# if you kick/get kicked all the time "just for fun" ...
 
8
 
 
9
use Irssi;
 
10
use Irssi::Irc;
 
11
use strict;
 
12
use vars qw($VERSION %IRSSI);
 
13
 
 
14
$VERSION = "1.00";
 
15
%IRSSI = (
 
16
    authors     => 'Timo Sirainen',
 
17
    name        => 'autorejoin',
 
18
    description => 'Automatically rejoin to channel after kicked',
 
19
    license     => 'Public Domain',
 
20
    changed     => 'Sun Mar 10 23:18 EET 2002'
 
21
);
 
22
 
 
23
sub channel_rejoin {
 
24
  my ($server, $channel) = @_;
 
25
 
 
26
  # check if channel has password
 
27
  my $chanrec = $server->channel_find($channel);
 
28
  my $password = $chanrec->{key} if ($chanrec);
 
29
 
 
30
  # We have to use send_raw() because the channel record still
 
31
  # exists and irssi won't even try to join to it with command()
 
32
  $server->send_raw("JOIN $channel $password");
 
33
}
 
34
 
 
35
sub event_rejoin_kick {
 
36
  my ($server, $data) = @_;
 
37
  my ($channel, $nick) = split(/ +/, $data);
 
38
 
 
39
  return if ($server->{nick} ne $nick);
 
40
 
 
41
  # check if we want to autorejoin this channel
 
42
  my @chans = split(/[ ,]+/, Irssi::settings_get_str('autorejoin_channels'));
 
43
  foreach my $chan (@chans) {
 
44
    if (lc($chan) eq lc($channel)) {
 
45
      channel_rejoin($server, $channel);
 
46
      last;
 
47
    }
 
48
  }
 
49
}
 
50
 
 
51
Irssi::settings_add_str('misc', 'autorejoin_channels', '');
 
52
Irssi::signal_add('event kick', 'event_rejoin_kick');