summaryrefslogtreecommitdiffstats
path: root/scripts/rainbow.pl
diff options
context:
space:
mode:
authorDavid Leadbeater2015-01-10 16:57:01 +0000
committerDavid Leadbeater2015-01-10 16:57:01 +0000
commitcbbdf2a1d93dbb64d3fb34346e9c57b14dfa2931 (patch)
tree019203a11e96a90be76a4538433e1d223a747d55 /scripts/rainbow.pl
parent0a3941245c1cbb55dd3c67af0b5c33caddd04f8b (diff)
parent71dba3f266191eeeff577303232d700fefe2e6e1 (diff)
downloadscripts.irssi.org-cbbdf2a1d93dbb64d3fb34346e9c57b14dfa2931.tar.bz2
Merge branch 'gh-pages' of gh:irssi/scripts.irssi.org into gh-pages
Conflicts: _data/scripts.yaml
Diffstat (limited to 'scripts/rainbow.pl')
-rw-r--r--scripts/rainbow.pl28
1 files changed, 27 insertions, 1 deletions
diff --git a/scripts/rainbow.pl b/scripts/rainbow.pl
index 3fc2375..0dd292d 100644
--- a/scripts/rainbow.pl
+++ b/scripts/rainbow.pl
@@ -13,6 +13,9 @@
#
# /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
@@ -20,7 +23,7 @@
use strict;
use vars qw($VERSION %IRSSI);
-$VERSION = "1.4";
+$VERSION = "1.6";
%IRSSI = (
authors => 'Jakub Jankowski',
contact => 'shasta@atn.pl',
@@ -47,6 +50,7 @@ my @colors = ('0', '4', '8', '9', '11', '12', '13');
# returns random-coloured string
sub make_colors {
my ($string) = @_;
+ Encode::_utf8_on($string);
my $newstr = "";
my $last = 255;
my $color = 0;
@@ -132,10 +136,30 @@ sub rkick {
}
}
+# 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:
#
@@ -144,3 +168,5 @@ Irssi::command_bind("rkick", "rkick");
# 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)