ModeAction OnModeChange(User* source, User* dest, Channel* chan, std::string& parameter, bool adding) { if (dest->IsModeSet(GetModeChar()) == adding) return MODEACTION_DENY; dest->SetMode(GetModeChar(), adding); LocalUser* const localuser = IS_LOCAL(dest); // Send snotices char snodest = localuser ? 'v' : 'V'; if (snoonset && adding) ServerInstance->SNO->WriteToSnoMask(snodest, "Oper %s has turned on override", dest->nick.c_str()); else if (!adding) { // IS_OPER check is needed to make sure we don't send snotices when the server unsets // the mode due to deopering if ((snoonunset) && (IS_OPER(dest)) && (!IS_SERVER(source))) ServerInstance->SNO->WriteToSnoMask(snodest, "Oper %s has turned off override", dest->nick.c_str()); } // Ignore remote users, their own server handles them if (localuser) { if (adding) { if (activetime > 0) activeopers.push_back(ActiveOper(localuser)); } else { // Remove this oper from the list for (ActiveOperList::iterator i = activeopers.begin(); i != activeopers.end(); ++i) { ActiveOper& item = *i; if (item.uuid == dest->uuid) { activeopers.erase(i); break; } } } } return MODEACTION_ALLOW; }
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { if (adding) { std::string::size_type colon = parameter.find(':'); if (colon == std::string::npos || parameter.find('-') != std::string::npos) { source->WriteNumeric(608, "%s %s :Invalid slowmode parameter", source->nick.c_str(),channel->name.c_str()); return MODEACTION_DENY; } /* Set up the slowmode parameters for this channel */ unsigned int nlines = ConvToInt(parameter.substr(0, colon)); unsigned int nsecs = ConvToInt(parameter.substr(colon+1)); if ((nlines < 2) || nsecs < 1) { source->WriteNumeric(608, "%s %s :Invalid slowmode parameter", source->nick.c_str(), channel->name.c_str()); return MODEACTION_DENY; } slowmodesettings* f = ext.get(channel); if (f && nlines == f->lines && nsecs == f->secs) // mode params match return MODEACTION_DENY; ext.set(channel, new slowmodesettings(nlines, nsecs)); parameter = ConvToStr(nlines) + ":" + ConvToStr(nsecs); channel->SetModeParam(GetModeChar(), parameter); return MODEACTION_ALLOW; } else { if (!channel->IsModeSet(GetModeChar())) return MODEACTION_DENY; ext.unset(channel); channel->SetModeParam(GetModeChar(), ""); return MODEACTION_ALLOW; } }
CustomPrefixMode(Module* parent, const std::string& Name, char Letter, char Prefix, ConfigTag* Tag) : PrefixMode(parent, Name, Letter, 0, Prefix) , tag(Tag) { unsigned long rank = tag->getUInt("rank", 0, 0, UINT_MAX); unsigned long setrank = tag->getUInt("ranktoset", prefixrank, rank, UINT_MAX); unsigned long unsetrank = tag->getUInt("ranktounset", setrank, setrank, UINT_MAX); bool depriv = tag->getBool("depriv", true); this->Update(rank, setrank, unsetrank, depriv); ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Created the %s prefix: letter=%c prefix=%c rank=%u ranktoset=%u ranktounset=%i depriv=%d", name.c_str(), GetModeChar(), GetPrefix(), GetPrefixRank(), GetLevelRequired(true), GetLevelRequired(false), CanSelfRemove()); }
ModeAction OnModeChange(User* source, User* dest, Channel* chan, std::string& parameter, bool adding) { if (adding) { std::string::size_type colon = parameter.find(':'); if (colon == std::string::npos || parameter.find('-') != std::string::npos) { source->WriteNumeric(608, "%s %s :Invalid join/part spam parameter", source->nick.c_str(), chan->name.c_str()); return MODEACTION_DENY; } unsigned int ncycles = ConvToInt(parameter.substr(0, colon)); unsigned int nsecs = ConvToInt(parameter.substr(colon+1)); if (ncycles < 2 || nsecs < 1) { source->WriteNumeric(608, "%s %s :Invalid join/part spam parameter", source->nick.c_str(), chan->name.c_str()); return MODEACTION_DENY; } joinpartspamsettings* jpss = ext.get(chan); if (jpss && ncycles == jpss->cycles && nsecs == jpss->secs) return MODEACTION_DENY; ext.set(chan, new joinpartspamsettings(ncycles, nsecs)); parameter = ConvToStr(ncycles) + ":" + ConvToStr(nsecs); chan->SetModeParam(GetModeChar(), parameter); return MODEACTION_ALLOW; } else { if (!chan->IsModeSet(GetModeChar())) return MODEACTION_DENY; ext.unset(chan); chan->SetModeParam(GetModeChar(), ""); return MODEACTION_ALLOW; } }