summaryrefslogtreecommitdiff
path: root/src/irc/notifylist
diff options
context:
space:
mode:
Diffstat (limited to 'src/irc/notifylist')
-rw-r--r--src/irc/notifylist/notify-commands.c16
-rw-r--r--src/irc/notifylist/notify-ison.c13
2 files changed, 15 insertions, 14 deletions
diff --git a/src/irc/notifylist/notify-commands.c b/src/irc/notifylist/notify-commands.c
index c51f33f3..1fb485e3 100644
--- a/src/irc/notifylist/notify-commands.c
+++ b/src/irc/notifylist/notify-commands.c
@@ -26,9 +26,7 @@
#include "notifylist.h"
-#define DEFAULT_NOTIFY_IDLE_TIME 60
-
-/* SYNTAX: NOTIFY [-away] [-idle [<minutes>]] <mask> [<ircnets>] */
+/* SYNTAX: NOTIFY [-away] [-idle [<time>]] <mask> [<ircnets>] */
static void cmd_notify(gchar *data)
{
GHashTable *optlist;
@@ -46,14 +44,16 @@ static void cmd_notify(gchar *data)
idletime = g_hash_table_lookup(optlist, "idle");
if (idletime == NULL)
idle_check_time = 0;
+ else if (*idletime == '\0')
+ idle_check_time = settings_get_time("notify_idle_time");
else {
- idle_check_time = is_numeric(idletime, 0) ? (atoi(idletime)*60) :
- (settings_get_int("notify_idle_time")*60);
+ if (!parse_time_interval(idletime, &idle_check_time))
+ cmd_return_error(CMDERR_INVALID_TIME);
}
away_check = g_hash_table_lookup(optlist, "away") != NULL;
notifylist_remove(mask);
- notifylist_add(mask, ircnets, away_check, idle_check_time);
+ notifylist_add(mask, ircnets, away_check, idle_check_time/1000);
cmd_params_free(free_arg);
}
@@ -77,11 +77,11 @@ static void cmd_unnotify(const char *data)
void notifylist_commands_init(void)
{
- settings_add_int("misc", "notify_idle_time", DEFAULT_NOTIFY_IDLE_TIME);
+ settings_add_time("misc", "notify_idle_time", "hour");
command_bind("notify", NULL, (SIGNAL_FUNC) cmd_notify);
command_bind("unnotify", NULL, (SIGNAL_FUNC) cmd_unnotify);
- command_set_options("notify", "@idle away");
+ command_set_options("notify", "-idle away");
}
void notifylist_commands_deinit(void)
diff --git a/src/irc/notifylist/notify-ison.c b/src/irc/notifylist/notify-ison.c
index 2de398a1..e27e3d60 100644
--- a/src/irc/notifylist/notify-ison.c
+++ b/src/irc/notifylist/notify-ison.c
@@ -29,8 +29,8 @@
#include "notifylist.h"
-#define DEFAULT_NOTIFY_CHECK_TIME 60
-#define DEFAULT_NOTIFY_WHOIS_TIME (60*5)
+#define DEFAULT_NOTIFY_CHECK_TIME "1min"
+#define DEFAULT_NOTIFY_WHOIS_TIME "5min"
typedef struct {
char *nick;
@@ -321,15 +321,16 @@ static void event_ison(IRC_SERVER_REC *server, const char *data)
static void read_settings(void)
{
if (notify_tag != -1) g_source_remove(notify_tag);
- notify_tag = g_timeout_add(1000*settings_get_int("notify_check_time"), (GSourceFunc) notifylist_timeout_func, NULL);
+ notify_tag = g_timeout_add(settings_get_time("notify_check_time"),
+ (GSourceFunc) notifylist_timeout_func, NULL);
- notify_whois_time = settings_get_int("notify_whois_time");
+ notify_whois_time = settings_get_time("notify_whois_time")/1000;
}
void notifylist_ison_init(void)
{
- settings_add_int("misc", "notify_check_time", DEFAULT_NOTIFY_CHECK_TIME);
- settings_add_int("misc", "notify_whois_time", DEFAULT_NOTIFY_WHOIS_TIME);
+ settings_add_time("misc", "notify_check_time", DEFAULT_NOTIFY_CHECK_TIME);
+ settings_add_time("misc", "notify_whois_time", DEFAULT_NOTIFY_WHOIS_TIME);
notify_tag = -1;
read_settings();