auto-set +s when +n is set (as +n requires +s) - allow +n to be 'set twice' allowing for snomask change without removal of +ns

Add default snomask chars


git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5063 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2006-08-29 19:12:05 +00:00
parent b9e99da4da
commit c0f8576bbd
5 changed files with 30 additions and 3 deletions

View File

@ -30,6 +30,7 @@ class SnomaskManager : public Extensible
private:
InspIRCd* ServerInstance;
SnoList SnoMasks;
void SetupDefaults();
public:
SnomaskManager(InspIRCd* Instance);
~SnomaskManager();

View File

@ -496,7 +496,7 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
}
else
{
targetuser->WriteServ("MODE %s %s",targetuser->nick,output_sequence.c_str());
targetuser->WriteServ("MODE %s %s%s",targetuser->nick,output_sequence.c_str(), parameter_list.str().c_str());
}
}
else
@ -509,7 +509,7 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
}
else
{
user->WriteTo(targetuser,"MODE %s %s",targetuser->nick,output_sequence.c_str());
user->WriteTo(targetuser,"MODE %s %s%s",targetuser->nick,output_sequence.c_str(), parameter_list.str().c_str());
FOREACH_MOD(I_OnMode,OnMode(user, targetuser, TYPE_USER, output_sequence));
}
}

View File

@ -18,6 +18,12 @@ ModeAction ModeUserServerNoticeMask::OnModeChange(userrec* source, userrec* dest
if (adding)
{
parameter = dest->ProcessNoticeMasks(parameter.c_str());
dest->modes[UM_SNOMASK] = true;
if (!dest->modes[UM_SERVERNOTICE])
{
const char* newmodes[] = { dest->nick, "+s" };
ServerInstance->Modes->Process(newmodes, 2, source, true);
}
return MODEACTION_ALLOW;
}
else if (dest->modes[UM_SNOMASK] != false)

View File

@ -27,6 +27,7 @@
SnomaskManager::SnomaskManager(InspIRCd* Instance) : ServerInstance(Instance)
{
SnoMasks.clear();
this->SetupDefaults();
}
SnomaskManager::~SnomaskManager()
@ -90,3 +91,17 @@ bool SnomaskManager::IsEnabled(char letter)
return (SnoMasks.find(letter) != SnoMasks.end());
}
void SnomaskManager::SetupDefaults()
{
this->EnableSnomask('c',"CONNECT"); /* Local connect notices */
this->EnableSnomask('C',"REMOTECONNECT"); /* Remote connect notices */
this->EnableSnomask('q',"QUIT"); /* Local quit notices */
this->EnableSnomask('Q',"REMOTEQUIT"); /* Remote quit notices */
this->EnableSnomask('k',"KILL"); /* Kill notices */
this->EnableSnomask('n',"NICK"); /* Nickchange notices */
this->EnableSnomask('l',"LINK"); /* Link notices */
this->EnableSnomask('o',"OPER"); /* Oper up/down notices */
this->EnableSnomask('d',"DEBUG"); /* Debug notices */
this->EnableSnomask('x',"XLINE"); /* Xline notice (g/z/q/k/e) */
}

View File

@ -98,8 +98,12 @@ std::string userrec::ProcessNoticeMasks(const char *sm)
const char *c = sm;
std::string output = "";
ServerInstance->Log(DEBUG,"Process notice masks");
while (c && *c)
{
ServerInstance->Log(DEBUG,"Process notice mask %c",*c);
switch (*c)
{
case '+':
@ -111,7 +115,7 @@ std::string userrec::ProcessNoticeMasks(const char *sm)
default:
if ((*c >= 'A') && (*c <= 'z') && (ServerInstance->SNO->IsEnabled(*c)))
{
if ((IsNoticeMaskSet(*c) && adding) || (!IsNoticeMaskSet(*c) && !adding))
if ((!IsNoticeMaskSet(*c) && adding) || (IsNoticeMaskSet(*c) && !adding))
{
if ((oldadding != adding) || (sm == c))
output += (adding ? '+' : '-');
@ -287,6 +291,7 @@ userrec::userrec(InspIRCd* Instance) : ServerInstance(Instance)
invites.clear();
chans.resize(MAXCHANS);
memset(modes,0,sizeof(modes));
memset(snomasks,0,sizeof(snomasks));
for (unsigned int n = 0; n < MAXCHANS; n++)
{