html/hello.pl
1 use strict;
2 use vars qw($VERSION %IRSSI);
3
4 use Irssi;
5
6 $VERSION = '1.00';
7 %IRSSI = (
8 authors => 'Cybertinus',
9 contact => 'cybertinus@cybertinus.nl',
10 name => 'Greeter',
11 description => 'This script allows ' .
12 'you to greet the channel ' .
13 'You\'re joining with the ' .
14 'command /hello. The text ' .
15 'it shows depends on the time ' .
16 'you\'re living.',
17 license => 'GPL2',
18 changed => "2005-05-25 13:42:00 GMT+1+DST"
19 );
20
21 sub hello
22 {
23 my($data, $server, $witem, $time, $text) = @_;
24 return unless $witem;
25 # $witem (window item) may be undef.
26
27 # getting the current hour off the day
28 $time = (localtime(time))[2];
29
30 if($time >= 18)
31 {
32 $text = Irssi::settings_get_str("evening_message");
33 }
34 elsif($time >= 12)
35 {
36 $text = Irssi::settings_get_str("afternoon_message");
37 }
38 elsif($time >= 6)
39 {
40 $text = Irssi::settings_get_str("morning_message");
41 }
42 elsif($time >= 0)
43 {
44 $text = Irssi::settings_get_str("night_message")
45 }
46 $server->command("MSG $witem->{name} $text $data");
47
48 }
49
50 Irssi::command_bind hello => \&hello;
51
52 Irssi::settings_add_str("greeter", "evening_message", "good evenening");
53 Irssi::settings_add_str("greeter", "afternoon_message", "good afternoon");
54 Irssi::settings_add_str("greeter", "morning_message", "good morning");
55 Irssi::settings_add_str("greeter", "night_message", "good night");