X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/1e7fd142966fbc2761e2f44c4c036facfdc8ddad..01fb744c405792dd3f0859a53f74cd4cb5fd166f:/modules/m_whois.c diff --git a/modules/m_whois.c b/modules/m_whois.c index ecd86569..68bb17c9 100644 --- a/modules/m_whois.c +++ b/modules/m_whois.c @@ -60,12 +60,14 @@ struct Message whois_msgtab = { int doing_whois_hook; int doing_whois_global_hook; int doing_whois_channel_visibility_hook; +int doing_whois_show_idle_hook; mapi_clist_av1 whois_clist[] = { &whois_msgtab, NULL }; mapi_hlist_av1 whois_hlist[] = { { "doing_whois", &doing_whois_hook }, { "doing_whois_global", &doing_whois_global_hook }, { "doing_whois_channel_visibility", &doing_whois_channel_visibility_hook }, + { "doing_whois_show_idle", &doing_whois_show_idle_hook }, { NULL, NULL } }; @@ -373,10 +375,23 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy) target_p->name, buf); } + /* fire the doing_whois_show_idle hook to allow modules to tell us whether to show the idle time */ + hook_data_client_approval hdata_showidle; + + hdata_showidle.client = source_p; + hdata_showidle.target = target_p; + hdata_showidle.approved = WHOIS_IDLE_SHOW; + + call_hook(doing_whois_show_idle_hook, &hdata_showidle); + sendto_one_numeric(source_p, RPL_WHOISIDLE, form_str(RPL_WHOISIDLE), - target_p->name, - (long)(rb_current_time() - target_p->localClient->last), - (unsigned long)target_p->localClient->firsttime); + target_p->name, + hdata_showidle.approved ? (long)(rb_current_time() - target_p->localClient->last) : 0, + (unsigned long)target_p->localClient->firsttime); + + if (hdata_showidle.approved == WHOIS_IDLE_AUSPEX || hdata_showidle.approved == WHOIS_IDLE_HIDE) + /* if the target has hidden their idle time, notify the source */ + sendto_one_numeric(source_p, RPL_WHOISTEXT, form_str(RPL_WHOISTEXT), target_p->name, "is using a private idle time"); } else {