After switching from tr-ircd to InspIRCd 2.0, a lot of users complained that there was no longer a usermode to hide their idle time in /whois. In order to remedy this, I chose a random unused usermode (+l) and implemented m_hideidle.so, which allows users to prevent idle time from being shown in /whois. Opers with priv users/auspex will still be able to see idle time, because it is important for opers with the correct privileges to be able to see information that normal users cannot.

If you plan on using this module, be sure to add information to your HELPOP scripts to tell users that mode +l is available and what it does.

/******************************************************************************
 *    InspIRCd 2.0 - m_hideidle.so
 *    Greg Malysa, 2011.
 *
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 ******************************************************************************
 *
 *    Third party module to provide usermode +l, which allows users to hide
 *    their idle time in /whois from normal users. Opers with users/auspex will
 *    always see idle times.
 *
 *****************************************************************************/

#include "inspircd.h"

// ModeHandler class for applying usermodes
class HideIdle : public ModeHandler {
public:
    HideIdle(Module *Creator) : ModeHandler(Creator, "hideidle", 'l', PARAM_NONE, MODETYPE_USER) {
        oper = false;
    }

    ModeAction OnModeChange(User *source, User *dest, Channel *channel, std::string &parameter, bool adding) {
        if (adding) {
            if (!dest->IsModeSet('l')) {
                dest->SetMode('l', true);
                return MODEACTION_ALLOW;
            }
        }
        else {
            if (dest->IsModeSet('l')) {
                dest->SetMode('l', false);
                return MODEACTION_ALLOW;
            }
        }
        return MODEACTION_DENY;
    }
};

// Module class interfaces with IRCD
class ModuleHideIdle : public Module {
    HideIdle hi;
public:
    ModuleHideIdle() : hi(this) {
        if (!ServerInstance->Modes->AddMode(&hi))
            throw ModuleException("Could not add +l (hide idle) usermode!");
        Implementation eventlist[] = {I_OnWhoisLine};
        ServerInstance->Modules->Attach(eventlist, this, 1);
    }
    virtual ~ModuleHideIdle() {}

    ModResult OnWhoisLine(User *user, User *dest, int &numeric, std::string &text) {
        // Check for the numeric about idle time and hide if necessary
        if (numeric == 317) {
            if (dest->IsModeSet('l') && !user->HasPrivPermission("users/auspex")) {
                return MOD_RES_DENY;
            }
        }

        // Default behavior is to show idle time
        return MOD_RES_PASSTHRU;
    }

    Version GetVersion() {
        return Version("Allows users to toggle their idle time being shown in /whois with usermode +l", 0);
    }
};

MODULE_INIT(ModuleHideIdle)