From 03929dac2a29664878d2c971648a4fe1fb698462 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 22:19:02 +0200 Subject: Adding upstream version 20231031. Signed-off-by: Daniel Baumann --- scripts/hello.pl | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 scripts/hello.pl (limited to 'scripts/hello.pl') diff --git a/scripts/hello.pl b/scripts/hello.pl new file mode 100644 index 0000000..e1dcd19 --- /dev/null +++ b/scripts/hello.pl @@ -0,0 +1,55 @@ +use strict; +use vars qw($VERSION %IRSSI); + +use Irssi; + +$VERSION = '1.00'; +%IRSSI = ( + authors => 'Cybertinus', + contact => 'cybertinus@cybertinus.nl', + name => 'Greeter', + description => 'This script allows ' . + 'you to greet the channel ' . + 'You\'re joining with the ' . + 'command /hello. The text ' . + 'it shows depends on the time ' . + 'you\'re living.', + license => 'GPL2', + changed => "2005-05-25 13:42:00 GMT+1+DST" +); + +sub hello +{ + my($data, $server, $witem, $time, $text) = @_; + return unless $witem; + # $witem (window item) may be undef. + + # getting the current hour off the day + $time = (localtime(time))[2]; + + if($time >= 18) + { + $text = Irssi::settings_get_str("evening_message"); + } + elsif($time >= 12) + { + $text = Irssi::settings_get_str("afternoon_message"); + } + elsif($time >= 6) + { + $text = Irssi::settings_get_str("morning_message"); + } + elsif($time >= 0) + { + $text = Irssi::settings_get_str("night_message") + } + $server->command("MSG $witem->{name} $text $data"); + +} + +Irssi::command_bind hello => \&hello; + +Irssi::settings_add_str("greeter", "evening_message", "good evenening"); +Irssi::settings_add_str("greeter", "afternoon_message", "good afternoon"); +Irssi::settings_add_str("greeter", "morning_message", "good morning"); +Irssi::settings_add_str("greeter", "night_message", "good night"); -- cgit v1.2.3