1# Prints private notices from people in the channel where they are joined
2# with you. Useful when you get lots of private notices from some bots.
3# for irssi 0.7.99 by Timo Sirainen
4
5# v1.01 - history:
6#   - fixed infinite loop when you weren't connected to server :)
7
8use strict;
9use Irssi;
10use vars qw($VERSION %IRSSI);
11$VERSION = "1.01";
12%IRSSI = (
13    authors     => "Timo Sirainen",
14    contact	=> "tss\@iki.fi",
15    name        => "notice move",
16    description => "Prints private notices from people in the channel where they are joined with you. Useful when you get lots of private notices from some bots.",
17    license	=> "Public Domain",
18    url		=> "http://irssi.org/",
19    changed	=> "2002-03-04T22:47+0100",
20    changes	=> "v1.01 - fixed infinite loop when you weren't connected to server :)"
21);
22
23my $insig = 0;
24
25sub sig_print_text {
26  my ($dest, $text, $stripped) = @_;
27  my $server = $dest->{server};
28
29  # ignore non-notices and notices in channels
30  return if (!$server ||
31	     !($dest->{level} & MSGLEVEL_NOTICES) ||
32	     $server->ischannel($dest->{target}));
33
34  return if ($insig);
35  $insig = 1;
36
37  # print the notice in the first channel the sender is joined
38  foreach my $channel ($server->channels()) {
39    if ($channel->nick_find($dest->{target})) {
40      $channel->print($text, MSGLEVEL_NOTICES);
41      Irssi::signal_stop();
42      last;
43    }
44  }
45
46  $insig = 0;
47}
48
49Irssi::signal_add('print text', 'sig_print_text');
50