Jul 132011

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
 *    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 {
	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);
		else {
			if (dest->IsModeSet('l')) {
				dest->SetMode('l', false);

// Module class interfaces with IRCD
class ModuleHideIdle : public Module {
	HideIdle hi;
	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

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


About Greg Malysa

I am a EE PhD student whose interests include computer architecture, analog circuit design, digital signal processing, and programming in a wide variety of languages. I do a lot of hands-on implementation work, such as doing PCB layout, assembling prototypes, and writing software for both embedded and general purpose systems. I also enjoy research and do many academic or proof-of-concept projects just to see if something can be done. If it involves electricity, I probably think it is interesting.

Leave a Reply