* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * InspIRCd: (C) 2002-2008 InspIRCd Development Team
* See: http://www.inspircd.org/wiki/index.php/Credits
*
* This program is free but copyrighted software; see
// have one of these structures associated with their user record.
typedef std::map<irc::string, time_t> silencelist;
-class cmd_silence : public Command
+class CommandSilence : public Command
{
unsigned int& maxsilence;
public:
- cmd_silence (InspIRCd* Instance, unsigned int &max) : Command(Instance,"SILENCE", 0, 0), maxsilence(max)
+ CommandSilence (InspIRCd* Instance, unsigned int &max) : Command(Instance,"SILENCE", 0, 0), maxsilence(max)
{
this->source = "m_silence.so";
syntax = "{[+|-]<mask>}";
TRANSLATE2(TR_TEXT, TR_END);
}
- CmdResult Handle (const char** parameters, int pcnt, User *user)
+ CmdResult Handle (const char* const* parameters, int pcnt, User *user)
{
if (!pcnt)
{
{
for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)
{
- user->WriteServ("271 %s %s %s :%lu",user->nick, user->nick, c->first.c_str(), (unsigned long)c->second);
+ user->WriteNumeric(271, "%s %s %s :%lu",user->nick, user->nick, c->first.c_str(), (unsigned long)c->second);
}
}
- user->WriteServ("272 %s :End of Silence List",user->nick);
+ user->WriteNumeric(272, "%s :End of Silence List",user->nick);
return CMD_SUCCESS;
}
if (i != sl->end())
{
sl->erase(i);
- user->WriteServ("950 %s %s :Removed %s from silence list",user->nick, user->nick, mask.c_str());
+ user->WriteNumeric(950, "%s %s :Removed %s from silence list",user->nick, user->nick, mask.c_str());
if (!sl->size())
{
// tidy up -- if a user's list is empty, theres no use having it
// hanging around in the user record.
- DELETE(sl);
+ delete sl;
user->Shrink("silence_list");
}
}
else
- user->WriteServ("952 %s %s :%s does not exist on your silence list",user->nick, user->nick, mask.c_str());
+ user->WriteNumeric(952, "%s %s :%s does not exist on your silence list",user->nick, user->nick, mask.c_str());
}
}
else if (action == '+')
silencelist::iterator n = sl->find(mask.c_str());
if (n != sl->end())
{
- user->WriteServ("952 %s %s :%s is already on your silence list",user->nick, user->nick, mask.c_str());
+ user->WriteNumeric(952, "%s %s :%s is already on your silence list",user->nick, user->nick, mask.c_str());
return CMD_FAILURE;
}
if (sl->size() >= maxsilence)
{
- user->WriteServ("952 %s %s :Your silence list is full",user->nick, user->nick, mask.c_str());
+ user->WriteNumeric(952, "%s %s :Your silence list is full",user->nick, user->nick, mask.c_str());
return CMD_FAILURE;
}
sl->insert(std::make_pair<irc::string, time_t>(mask.c_str(), ServerInstance->Time()));
- user->WriteServ("951 %s %s :Added %s to silence list",user->nick, user->nick, mask.c_str());
+ user->WriteNumeric(951, "%s %s :Added %s to silence list",user->nick, user->nick, mask.c_str());
return CMD_SUCCESS;
}
}
class ModuleSilence : public Module
{
- cmd_silence* mycommand;
+ CommandSilence* mycommand;
unsigned int maxsilence;
public:
: Module(Me), maxsilence(32)
{
OnRehash(NULL, "");
- mycommand = new cmd_silence(ServerInstance, maxsilence);
+ mycommand = new CommandSilence(ServerInstance, maxsilence);
ServerInstance->AddCommand(mycommand);
+ Implementation eventlist[] = { I_OnRehash, I_OnUserQuit, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage };
+ ServerInstance->Modules->Attach(eventlist, this, 5);
}
- void Implements(char* List)
- {
- List[I_OnRehash] = List[I_OnUserQuit] = List[I_On005Numeric] = List[I_OnUserPreNotice] = List[I_OnUserPreMessage] = 1;
- }
virtual void OnRehash(User* user, const std::string ¶meter)
{
user->GetExt("silence_list", sl);
if (sl)
{
- DELETE(sl);
+ delete sl;
user->Shrink("silence_list");
}
}
virtual Version GetVersion()
{
- return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
+ return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
};