diff options
| author | Alexander Færøy | 2014-05-31 13:10:46 +0200 | 
|---|---|---|
| committer | Alexander Færøy | 2014-05-31 13:10:46 +0200 | 
| commit | 2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1 (patch) | |
| tree | 1c5e6d817c88e67b46e216a50e0aef5428bf63df /scripts/hello.pl | |
| parent | 2d080422d79d1fd49d6c5528593ccaaff9bfc583 (diff) | |
| download | scripts.irssi.org-2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1.tar.bz2 | |
Import scripts from scripts.irssi.org
Diffstat (limited to 'scripts/hello.pl')
| -rw-r--r-- | scripts/hello.pl | 55 | 
1 files changed, 55 insertions, 0 deletions
| 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"); | 
