/usr/share/irssi/scripts/rainbow.pl is in irssi-scripts 20160301.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | #!/usr/bin/perl -w
# USAGE:
#
# /RSAY <text>
# - same as /say, but outputs a coloured text
#
# /RME <text>
# - same as /me, but outputs a coloured text
#
# /RTOPIC <text>
# - same as /topic, but outputs a coloured text :)
#
# /RKICK <nick> [reason]
# - kicks nick from the current channel with coloured reason
#
# /RKNOCKOUT [time] <nicks> [reason]
# - knockouts nicks from the current channel with coloured reason for time
# Written by Jakub Jankowski <shasta@atn.pl>
# for Irssi 0.7.98.4 and newer
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = "1.6";
%IRSSI = (
authors => 'Jakub Jankowski',
contact => 'shasta@atn.pl',
name => 'rainbow',
description => 'Prints colored text. Rather simple than sophisticated.',
license => 'GNU GPLv2 or later',
url => 'http://irssi.atn.pl/',
);
use Irssi;
use Irssi::Irc;
use Encode;
# colors list
# 0 == white
# 4 == light red
# 8 == yellow
# 9 == light green
# 11 == light cyan
# 12 == light blue
# 13 == light magenta
my @colors = ('0', '4', '8', '9', '11', '12', '13');
# str make_colors($string)
# returns random-coloured string
sub make_colors {
my ($string) = @_;
Encode::_utf8_on($string);
my $newstr = "";
my $last = 255;
my $color = 0;
for (my $c = 0; $c < length($string); $c++) {
my $char = substr($string, $c, 1);
if ($char eq ' ') {
$newstr .= $char;
next;
}
while (($color = int(rand(scalar(@colors)))) == $last) {};
$last = $color;
$newstr .= "\003";
$newstr .= sprintf("%02d", $colors[$color]);
$newstr .= $char;
}
return $newstr;
}
# void rsay($text, $server, $destination)
# handles /rsay
sub rsay {
my ($text, $server, $dest) = @_;
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
return unless $dest;
if ($dest->{type} eq "CHANNEL" || $dest->{type} eq "QUERY") {
$dest->command("/msg " . $dest->{name} . " " . make_colors($text));
}
}
# void rme($text, $server, $destination)
# handles /rme
sub rme {
my ($text, $server, $dest) = @_;
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
if ($dest && ($dest->{type} eq "CHANNEL" || $dest->{type} eq "QUERY")) {
$dest->command("/me " . make_colors($text));
}
}
# void rtopic($text, $server, $destination)
# handles /rtopic
sub rtopic {
my ($text, $server, $dest) = @_;
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
if ($dest && $dest->{type} eq "CHANNEL") {
$dest->command("/topic " . make_colors($text));
}
}
# void rkick($text, $server, $destination)
# handles /rkick
sub rkick {
my ($text, $server, $dest) = @_;
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
if ($dest && $dest->{type} eq "CHANNEL") {
my ($nick, $reason) = split(/ +/, $text, 2);
return unless $nick;
$reason = "Irssi power!" if ($reason =~ /^[\ ]*$/);
$dest->command("/kick " . $nick . " " . make_colors($reason));
}
}
# void rknockout($text, $server, $destination)
# handles /rknockout
sub rknockout {
my ($text, $server, $dest) = @_;
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
if ($dest && $dest->{type} eq "CHANNEL") {
my ($time, $nick, $reason) = split(/ +/, $text, 3);
($time, $nick, $reason) = (300, $time, $nick . " " . $reason) if ($time !~ m/^\d+$/);
return unless $nick;
$reason = "See you in " . $time . " seconds!" if ($reason =~ /^[\ ]*$/);
$dest->command("/knockout " . $time . " " . $nick . " " . make_colors($reason));
}
}
Irssi::command_bind("rsay", "rsay");
Irssi::command_bind("rtopic", "rtopic");
Irssi::command_bind("rme", "rme");
Irssi::command_bind("rkick", "rkick");
Irssi::command_bind("rknockout", "rknockout");
# changes:
#
# 25.01.2002: Initial release (v1.0)
# 26.01.2002: /rtopic added (v1.1)
# 29.01.2002: /rsay works with dcc chats now (v1.2)
# 02.02.2002: make_colors() doesn't assign any color to spaces (v1.3)
# 23.02.2002: /rkick added
# 26.11.2014: utf-8 support
# 01.12.2014: /rknockout added (v1.6)
|