* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * InspIRCd: (C) 2002-2010 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
* the file COPYING for details.
class CommandSamode : public Command
{
public:
- CommandSamode (InspIRCd* Instance) : Command(Instance,"SAMODE", "o", 2, false, 0)
+ bool active;
+ CommandSamode(Module* Creator) : Command(Creator,"SAMODE", 2)
{
- this->source = "m_samode.so";
- syntax = "<target> <modes> {<mode-parameters>}";
+ flags_needed = 'o'; Penalty = 0; syntax = "<target> <modes> {<mode-parameters>}";
+ active = false;
}
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
- /*
- * Handles an SAMODE request. Notifies all +s users.
- */
- ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
-
+ this->active = true;
+ ServerInstance->Parser->CallHandler("MODE", parameters, user);
if (ServerInstance->Modes->GetLastParse().length())
- {
- ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick) + " used SAMODE: " + ServerInstance->Modes->GetLastParse());
-
- std::deque<std::string> n;
- irc::spacesepstream spaced(ServerInstance->Modes->GetLastParse());
- std::string one;
- while (spaced.GetToken(one))
- n.push_back(one);
-
- std::string channel = n[0];
- n.pop_front();
- ServerInstance->PI->SendMode(channel, n);
-
- /* XXX: Yes, this is right. We dont want to propagate the
- * actual SAMODE command, just the MODE command generated
- * by the Protocol Interface
- */
- return CMD_LOCALONLY;
- }
- else
- {
- user->WriteServ("NOTICE %s :*** Invalid SAMODE sequence.", user->nick.c_str());
- }
-
- return CMD_FAILURE;
+ ServerInstance->SNO->WriteGlobalSno('a', std::string(user->nick) + " used SAMODE: " +ServerInstance->Modes->GetLastParse());
+ this->active = false;
+ return CMD_SUCCESS;
}
};
class ModuleSaMode : public Module
{
- CommandSamode* mycommand;
+ CommandSamode cmd;
public:
- ModuleSaMode(InspIRCd* Me)
- : Module(Me)
+ ModuleSaMode()
+ : cmd(this)
{
+ ServerInstance->AddCommand(&cmd);
+ ServerInstance->Modules->Attach(I_OnPreMode, this);
+ }
- mycommand = new CommandSamode(ServerInstance);
- ServerInstance->AddCommand(mycommand);
+ ~ModuleSaMode()
+ {
+ }
+ Version GetVersion()
+ {
+ return Version("Provides more advanced UnrealIRCd SAMODE command", VF_VENDOR);
}
- virtual ~ModuleSaMode()
+ ModResult OnPreMode(User* source,User* dest,Channel* channel, const std::vector<std::string>& parameters)
{
+ if (cmd.active)
+ return MOD_RES_ALLOW;
+ return MOD_RES_PASSTHRU;
}
- virtual Version GetVersion()
+ void Prioritize()
{
- return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
+ Module *override = ServerInstance->Modules->Find("m_override.so");
+ ServerInstance->Modules->SetPriority(this, I_OnPreMode, PRIORITY_BEFORE, &override);
}
};