1use strict;
2use Irssi;
3use Irssi::Irc;
4
5use vars qw($VERSION %IRSSI);
6
7$VERSION = "1.0";
8%IRSSI = (
9	"authors"       => "Mantis",
10	"contact"       => "mantis\@inta-link.com",
11	"name"          => "highlite",
12	"description"   => "shows events happening in all channels you are in that may concern you",
13	"url"           => "http://www.inta-link.com/",
14	"license"       => "GNU GPL v2",
15	"changed"       => "2003-01-03"
16);
17
18sub msg_join
19{
20  my ($server, $channame, $nick, $host) = @_;
21  $channame =~ s/^://;
22
23  my $windowname = Irssi::window_find_name('highlite');
24  $windowname->print("%B%0JOIN : " . $nick . " : " . $channame . " : " . $host, MSGLEVEL_CLIENTCRAP) if ($windowname);
25}
26
27sub msg_part
28{
29  my ($server, $channame, $nick, $host) = @_;
30  $channame =~ s/^://;
31
32  my $windowname = Irssi::window_find_name('highlite');
33  $windowname->print("%b%0PART : " . $nick . " : " . $channame . " : " . $host, MSGLEVEL_CLIENTCRAP) if ($windowname);
34}
35
36sub msg_quit
37{
38  my ($server, $nick, $host, $quitmsg) = @_;
39
40  if (substr($quitmsg, 0, 14) eq "Read error to ")
41  {
42    $quitmsg = "[ General Read Error ]";
43  }
44  if (substr($quitmsg, 0, 17) eq "Ping timeout for ")
45  {
46    $quitmsg = "[ General Ping Timeout Error ]";
47  }
48
49  my $windowname = Irssi::window_find_name('highlite');
50  $windowname->print("%R%0QUIT : " . $nick . " : " . $host . " : " . $quitmsg, MSGLEVEL_CLIENTCRAP) if ($windowname);
51
52  $quitmsg = "";
53}
54
55sub msg_topic
56{
57  my ($server, $channame, $topicmsg, $nick, $host) = @_;
58  $channame =~ s/^://;
59
60  my $windowname = Irssi::window_find_name('highlite');
61  $windowname->print("%G%0TOPIC : " . $nick . " : " . $channame . " : " . $topicmsg, MSGLEVEL_CLIENTCRAP) if ($windowname);
62}
63
64sub msg_nick
65{
66  my ($server, $nick, $old_nick, $host) = @_;
67
68  my $windowname = Irssi::window_find_name('highlite');
69  $windowname->print("%m%0NICK : " . $old_nick . " : " . $nick . " : " . $host, MSGLEVEL_CLIENTCRAP) if ($windowname);
70}
71
72sub msg_kick
73{
74  my ($server, $channame, $kicked, $nick, $host, $reason) = @_;
75  $channame =~ s/^://;
76
77  my $windowname = Irssi::window_find_name('highlite');
78  $windowname->print("%Y%0KICK : " . $kicked . " : " . $channame . " : " . $nick . " : " . $reason, MSGLEVEL_CLIENTCRAP) if ($windowname);
79}
80
81sub sig_printtext {
82  my ($dest, $text, $stripped) = @_;
83
84  if (($dest->{level} & (MSGLEVEL_HILIGHT|MSGLEVEL_MSGS)) && ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0)
85  {
86    if ($dest->{level} & MSGLEVEL_PUBLIC)
87    {
88      my $windowname = Irssi::window_find_name('highlite');
89
90      $windowname->print("%W%0HIGHLITE : " . $dest->{target} . " : " . $text, MSGLEVEL_CLIENTCRAP) if ($windowname);
91    }
92  }
93}
94
95my $windowname = Irssi::window_find_name('highlite');
96if (!$windowname)
97{
98  Irssi::command("window new hidden");
99  Irssi::command("window name highlite");
100}
101
102Irssi::signal_add(
103{
104  'message join' => \&msg_join,
105  'message part' => \&msg_part,
106  'message quit' => \&msg_quit,
107  'message topic' => \&msg_topic,
108  'print text', 'sig_printtext',
109  'message nick' => \&msg_nick,
110  'message kick' => \&msg_kick
111}
112);
113
114