/usr/share/irssi/scripts/relm.pl is in irssi-scripts 20131030.
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 | ## Usage: /RELM [-l || index] [target]
## to list last 15 messages:
## /RELM -l
## to redirect msg #4, 7, 8, 9, 10, 13 to current channel/query:
## /RELM 4,7-10,13
## to redirect last message to current channel/query:
## /RELM
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "1.0";
%IRSSI = (
authors => "Maciek \'fahren\' Freudenheim",
contact => "fahren\@bochnia.pl",
name => "REdirect Last Message",
description => "Keeps last 15 messages in cache",
license => "GNU GPLv2 or later",
changed => "Fri Mar 15 15:09:42 CET 2002"
);
sub cmd_relm {
my ($args, $server, $winit) = @_;
my $ircnet = lc($server->{tag});
my ($which, $where) = split(/ +/, $args, 2);
$where = $which unless $which =~ /[0-9]/;
$which = scalar(@{$relm{lc($ircnet)}}) unless ($which);
unless (@relm{$ircnet}) {
Irssi::print("%R>>%n Nothing in relm buffer on $ircnet.", MSGLEVEL_CRAP);
return;
}
if ($where eq "-l") {
my $numspace;
Irssi::print(">> ---- Context ------------------------", MSGLEVEL_CRAP);
for (my $i = 0; $i < scalar(@{$relm{$ircnet}}); $i++) {
$numspace = sprintf("%.2d", $i+1);
Irssi::print("[%W$numspace%n] $relm{$ircnet}[$i]", MSGLEVEL_CRAP);
}
return;
}
unless ($where) {
unless ($winit && ($winit->{type} eq "CHANNEL" || $winit->{type} eq "QUERY")) {
Irssi::print("%R>>%n You have to join channel first", MSGLEVEL_CRAP);
return;
}
$where = $winit->{name};
}
$which =~ s/,/ /g;
my @nums;
for my $num (split(/ /, $which)) {
if ($num =~ /-/) {
my ($start, $end) = $num =~ /([0-9]+)-([0-9]*)/;
for (;$start <= $end; $start++) {
push(@nums, $start - 1);
}
} else {
push(@nums, $num - 1);
}
}
for my $num (@nums) {
unless ($relm{$ircnet}[$num]) {
Irssi::print("%R>>%n No such message in relm buffer /" . ($num + 1). "/", MSGLEVEL_CRAP);
} else {
Irssi::active_server()->command("msg $where $relm{$ircnet}[$num]");
}
}
}
sub event_privmsg {
my ($server, $data, $nick, $address) = @_;
my ($target, $text) = split(/ :/, $data, 2);
my $ircnet = lc($server->{tag});
return if ($server->{nick} ne $target);
my $relm = "\00312[ \00310$nick!$address \00312]\003 $text";
shift(@{$relm{$ircnet}}) if scalar(@{$relm{$ircnet}}) > 14;
push(@{$relm{$ircnet}}, $relm);
}
Irssi::command_bind("relm", "cmd_relm");
Irssi::signal_add("event privmsg", "event_privmsg");
|