-
Notifications
You must be signed in to change notification settings - Fork 234
/
ziew.pl
123 lines (100 loc) · 2.67 KB
/
ziew.pl
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
# /ziew ile
# Grzegorz Jaskiewicz aka giejot 2004
# credits to Smiechu for help
use strict;
use Irssi;
use Irssi qw(command_bind command signal_add_last signal_stop settings_get_bool settings_add_bool);
use vars qw($VERSION %IRSSI);
%IRSSI = (
authors => "Grzegorz Jaskiewicz",
contact => "gj\@pointblue.com.pl",
name => "ziew",
description => "yawners toy",
license => "GPLv2",
url => "http://gj.pointblue.com.pl/projects/ziew",
);
$VERSION = "0.56";
my $iscolor=0;
#rozne wersje jezykowe ziewow
my %ziew = (
"pl" => [ "zi", "e", "w" ],
"en" => [ "y", "a", "wn" ],
"jp" => [ "ak", "u", "bi" ],
"de" => [ "gä", "h", "nen" ],
"fr" => [ "bâil", "l", "er" ],
);
## stolen from rainbow.pl
# 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) = @_;
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) {};
$color = int(rand(scalar(@colors)));
$last = $color;
$newstr .= "\003";
$newstr .= sprintf("%02d", $colors[$color]);
$newstr .= (($char eq ",") ? ",," : $char);
}
return $newstr;
}
sub ziewaj($$) {
my( $ilosc, $lang ) = @_;
if (!$ziew{ $lang }->[0]) {
$lang="pl";
}
return $ziew{$lang}->[0].($ziew{$lang}->[1]x$ilosc).$ziew{$lang}->[2];
}
sub cmd_yawn {
my $out;
my $i;
my $l;
my @args = split(/ +/, $_[0]);
( $i, $l ) = @args;
if ( $i <=0 ) {
Irssi::print("ziew.pl: parametrem musi byc dodatnia liczba", MSGLEVEL_CRAP);
return;
}
$out = ziewaj( $i, $l );
if ( $iscolor) {
$out = make_colors( $out );
}
my $window = Irssi::active_win();
$window->command( "/say ".$out );
}
sub cmd_ryawn {
$iscolor=1;
cmd_yawn(@_);
$iscolor=0;
}
Irssi::command_bind('yawn', 'cmd_yawn');
Irssi::command_bind('ryawn', 'cmd_ryawn');
Irssi::print("--------------------------------------");
Irssi::print("/yawn En [en|pl|jp|de|fr]");
Irssi::print("En - ilosc 'e' w ziew");
Irssi::print("");
Irssi::print("/ryawn En [en|pl|jp|de|fr]");
Irssi::print("En - ilosc 'e' w ziew, w kolorkach!");
Irssi::print("");
Irssi::print("drugi parametr to jezyk, narazie obsluguje en,jp,de,fr,pl");
Irssi::print("pl jest domyslne");
Irssi::print("");
Irssi::print("wiecej opcji na gwiazdke w przyszlym roku ;)");
Irssi::print("--------------------------------------");