blob: ff9417a3b3c4d1be39e0a92edefa142951c3cf27 (
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
|
# 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;
}
|