mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-25 10:29:01 -04:00
Modified m_silence to take masks instead of nicknames. Since this is *much* more CPU intensive, we should probably put in a maximum number of entries soon
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4943 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
e381b06561
commit
77a4fbd1c4
@ -22,9 +22,9 @@ using namespace std;
|
|||||||
#include "users.h"
|
#include "users.h"
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "modules.h"
|
#include "modules.h"
|
||||||
|
|
||||||
#include "hashcomp.h"
|
#include "hashcomp.h"
|
||||||
#include "inspircd.h"
|
#include "inspircd.h"
|
||||||
|
#include "wildcard.h"
|
||||||
|
|
||||||
/* $ModDesc: Provides support for the /SILENCE command */
|
/* $ModDesc: Provides support for the /SILENCE command */
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ class cmd_silence : public command_t
|
|||||||
cmd_silence (InspIRCd* Instance) : command_t(Instance,"SILENCE", 0, 0)
|
cmd_silence (InspIRCd* Instance) : command_t(Instance,"SILENCE", 0, 0)
|
||||||
{
|
{
|
||||||
this->source = "m_silence.so";
|
this->source = "m_silence.so";
|
||||||
syntax = "{[+|-]<nick>}";
|
syntax = "{[+|-]<mask>}";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle (const char** parameters, int pcnt, userrec *user)
|
void Handle (const char** parameters, int pcnt, userrec *user)
|
||||||
@ -56,7 +56,7 @@ class cmd_silence : public command_t
|
|||||||
{
|
{
|
||||||
for (silencelist::const_iterator c = sl->begin(); c < sl->end(); c++)
|
for (silencelist::const_iterator c = sl->begin(); c < sl->end(); c++)
|
||||||
{
|
{
|
||||||
user->WriteServ("271 %s %s %s!*@*",user->nick, user->nick,c->c_str());
|
user->WriteServ("271 %s %s %s",user->nick, user->nick,c->c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
user->WriteServ("272 %s :End of Silence List",user->nick);
|
user->WriteServ("272 %s :End of Silence List",user->nick);
|
||||||
@ -64,11 +64,19 @@ class cmd_silence : public command_t
|
|||||||
else if (pcnt > 0)
|
else if (pcnt > 0)
|
||||||
{
|
{
|
||||||
// one or more parameters, add or delete entry from the list (only the first parameter is used)
|
// one or more parameters, add or delete entry from the list (only the first parameter is used)
|
||||||
const char *nick = parameters[0];
|
std::string mask = parameters[0] + 1;
|
||||||
if (nick[0] == '-')
|
char action = *parameters[0];
|
||||||
|
|
||||||
|
if (!mask.length())
|
||||||
|
{
|
||||||
|
// 'SILENCE +' or 'SILENCE -', assume *!*@*
|
||||||
|
mask = "*!*@*";
|
||||||
|
}
|
||||||
|
|
||||||
|
ModeParser::CleanMask(mask);
|
||||||
|
|
||||||
|
if (action == '-')
|
||||||
{
|
{
|
||||||
// removing an item from the list
|
|
||||||
nick++;
|
|
||||||
// fetch their silence list
|
// fetch their silence list
|
||||||
silencelist* sl;
|
silencelist* sl;
|
||||||
user->GetExt("silence_list", sl);
|
user->GetExt("silence_list", sl);
|
||||||
@ -81,13 +89,11 @@ class cmd_silence : public command_t
|
|||||||
{
|
{
|
||||||
// search through for the item
|
// search through for the item
|
||||||
irc::string listitem = i->c_str();
|
irc::string listitem = i->c_str();
|
||||||
irc::string target = nick;
|
if (listitem == mask)
|
||||||
if (listitem == target)
|
|
||||||
{
|
{
|
||||||
sl->erase(i);
|
sl->erase(i);
|
||||||
user->WriteServ("950 %s %s :Removed %s!*@* from silence list",user->nick, user->nick,nick);
|
user->WriteServ("950 %s %s :Removed %s from silence list",user->nick, user->nick, mask.c_str());
|
||||||
// we have modified the vector from within a loop, we must now bail out
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,9 +106,8 @@ class cmd_silence : public command_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (nick[0] == '+')
|
else if (action == '+')
|
||||||
{
|
{
|
||||||
nick++;
|
|
||||||
// fetch the user's current silence list
|
// fetch the user's current silence list
|
||||||
silencelist* sl;
|
silencelist* sl;
|
||||||
user->GetExt("silence_list", sl);
|
user->GetExt("silence_list", sl);
|
||||||
@ -112,19 +117,17 @@ class cmd_silence : public command_t
|
|||||||
sl = new silencelist;
|
sl = new silencelist;
|
||||||
user->Extend(std::string("silence_list"), sl);
|
user->Extend(std::string("silence_list"), sl);
|
||||||
}
|
}
|
||||||
// add the nick to it -- silence only takes nicks for some reason even though its list shows masks
|
|
||||||
for (silencelist::iterator n = sl->begin(); n != sl->end(); n++)
|
for (silencelist::iterator n = sl->begin(); n != sl->end(); n++)
|
||||||
{
|
{
|
||||||
irc::string listitem = n->c_str();
|
irc::string listitem = n->c_str();
|
||||||
irc::string target = nick;
|
if (listitem == mask)
|
||||||
if (listitem == target)
|
|
||||||
{
|
{
|
||||||
user->WriteServ("952 %s %s :%s is already on your silence list",user->nick, user->nick,nick);
|
user->WriteServ("952 %s %s :%s is already on your silence list",user->nick, user->nick, mask.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sl->push_back(std::string(nick));
|
sl->push_back(mask);
|
||||||
user->WriteServ("951 %s %s :Added %s!*@* to silence list",user->nick, user->nick,nick);
|
user->WriteServ("951 %s %s :Added %s to silence list",user->nick, user->nick, mask.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,9 +188,7 @@ class ModuleSilence : public Module
|
|||||||
{
|
{
|
||||||
for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)
|
for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)
|
||||||
{
|
{
|
||||||
irc::string listitem = c->c_str();
|
if (match(user->GetFullHost(), c->c_str()))
|
||||||
irc::string target = user->nick;
|
|
||||||
if (listitem == target)
|
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user