summaryrefslogtreecommitdiffstats
path: root/scripts/highlite.pl
blob: 515d0ddc054a9392daee40d69c797787691c606c (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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
use strict;
use Irssi;
use Irssi::Irc;

use vars qw($VERSION %IRSSI);

$VERSION = "1.0";
%IRSSI = (
	"authors"       => "Mantis",
	"contact"       => "mantis\@inta-link.com",
	"name"          => "highlite",
	"description"   => "shows events happening in all channels you are in that may concern you",
	"url"           => "http://www.inta-link.com/",
	"license"       => "GNU GPL v2",
	"changed"       => "2003-01-03"
);

sub msg_join
{
  my ($server, $channame, $nick, $host) = @_;
  $channame =~ s/^://;

  my $windowname = Irssi::window_find_name('highlite');
  $windowname->print("%B%0JOIN : " . $nick . " : " . $channame . " : " . $host, MSGLEVEL_CLIENTCRAP) if ($windowname);
}

sub msg_part
{
  my ($server, $channame, $nick, $host) = @_;
  $channame =~ s/^://;

  my $windowname = Irssi::window_find_name('highlite');
  $windowname->print("%b%0PART : " . $nick . " : " . $channame . " : " . $host, MSGLEVEL_CLIENTCRAP) if ($windowname);
}

sub msg_quit
{
  my ($server, $nick, $host, $quitmsg) = @_;

  if (substr($quitmsg, 0, 14) eq "Read error to ")
  {
    $quitmsg = "[ General Read Error ]";
  }
  if (substr($quitmsg, 0, 17) eq "Ping timeout for ")
  {
    $quitmsg = "[ General Ping Timeout Error ]";
  }

  my $windowname = Irssi::window_find_name('highlite');
  $windowname->print("%R%0QUIT : " . $nick . " : " . $host . " : " . $quitmsg, MSGLEVEL_CLIENTCRAP) if ($windowname);

  $quitmsg = "";
}

sub msg_topic
{
  my ($server, $channame, $topicmsg, $nick, $host) = @_;
  $channame =~ s/^://;

  my $windowname = Irssi::window_find_name('highlite');
  $windowname->print("%G%0TOPIC : " . $nick . " : " . $channame . " : " . $topicmsg, MSGLEVEL_CLIENTCRAP) if ($windowname);
}

sub msg_nick
{
  my ($server, $nick, $old_nick, $host) = @_;

  my $windowname = Irssi::window_find_name('highlite');
  $windowname->print("%m%0NICK : " . $old_nick . " : " . $nick . " : " . $host, MSGLEVEL_CLIENTCRAP) if ($windowname);
}

sub msg_kick
{
  my ($server, $channame, $kicked, $nick, $host, $reason) = @_;
  $channame =~ s/^://;

  my $windowname = Irssi::window_find_name('highlite');
  $windowname->print("%Y%0KICK : " . $kicked . " : " . $channame . " : " . $nick . " : " . $reason, MSGLEVEL_CLIENTCRAP) if ($windowname);
}

sub sig_printtext {
  my ($dest, $text, $stripped) = @_;

  if (($dest->{level} & (MSGLEVEL_HILIGHT|MSGLEVEL_MSGS)) && ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0)
  {
    if ($dest->{level} & MSGLEVEL_PUBLIC)
    {
      my $windowname = Irssi::window_find_name('highlite');

      $windowname->print("%W%0HIGHLITE : " . $dest->{target} . " : " . $text, MSGLEVEL_CLIENTCRAP) if ($windowname);
    }
  }
}

my $windowname = Irssi::window_find_name('highlite');
if (!$windowname)
{
  Irssi::command("window new hidden");
  Irssi::command("window name highlite");
}

Irssi::signal_add(
{
  'message join' => \&msg_join,
  'message part' => \&msg_part,
  'message quit' => \&msg_quit,
  'message topic' => \&msg_topic,
  'print text', 'sig_printtext',
  'message nick' => \&msg_nick,
  'message kick' => \&msg_kick
}
);