File: hello.pl

package info (click to toggle)
weechat-scripts 20071011
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 400 kB
  • ctags: 377
  • sloc: python: 3,470; perl: 1,305; ruby: 270; makefile: 37
file content (34 lines) | stat: -rw-r--r-- 1,072 bytes parent folder | download | duplicates (2)
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
# This script is a port from the hello.pl irssi script written by
# Cybertinus <cybertinus@cybertinus.nl>
# 
# Licensed under the GPL v2
#
# Author: Julien Louis <ptitlouis@sysif.net>

weechat::register("hello" ,"0.1", "", "Display greetings depending the time");

weechat::add_command_handler("hello", hello, "", "Send greetings to the current buffer");

weechat::set_plugin_config("evening_message", "good evening");
weechat::set_plugin_config("afternoon_message", "good afternoon");
weechat::set_plugin_config("morning_message", "good morning");
weechat::set_plugin_config("night_message", "good night");


sub hello {
	my ($server,$data) = @_;

	$time = (localtime(time))[2];
	if ($time >= 18) {
		$text = weechat::get_plugin_config("evening_message");
	} elsif ($time >= 12) {
		$text = weechat::get_plugin_config("afternoon_message");
	} elsif ($time >= 6) {
		$text = weechat::get_plugin_config("morning_message");
	} elsif ($time >= 0) {
		$text = weechat::get_plugin_config("night_message");
	}
	weechat::command("$text $data");
	return weechat::PLUGIN_RC_OK;
}