summaryrefslogtreecommitdiffstats
path: root/scripts/smiley.pl
blob: d81437b053a4d8de7842be23e019438f6c921d00 (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
use Irssi;
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = '0.69';

%IRSSI = (
	authors		=> 'Jonne Piittinen',
	contact		=> 'jip@loota.org',
	name		=> 'Smiley',
	description	=> 'Very useful smiley-flooder',
	license		=> 'Public Domain',
);

print "<--------[------------------------------]-------->";
print "<--------[    smiley-script v. $VERSION.    ]-------->";
print "<--------[ /smiley to generate a smiley ]-------->";
print "<--------[------------------------------]-------->";

sub gen_smiley {

	my ($data, $server, $witem) = @_;
	my @smilies;
	my $string;
	my $i;

	@smilies = (':)',':D',';D',':P',':>','=D','=)',':E',':]');

	for ($i = 0; $i < 100; $i++) {
		if (rand(4) > 2 && $i > 0 && $string !~ / $/) {
			$string .= " ";
		} else {
			$string .= @smilies[rand($#smilies-1)];
		}
	}
	
	if ($witem) {
		$witem->command("MSG ".$witem->{name}." ".$string);
	} else {
		Irssi::print("No active channel or query in this window.");
	}
}

Irssi::command_bind('smiley', 'gen_smiley');