1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
20 * SAMODE module for InspIRCd
21 * Co authored by Brain and w00t
23 * Syntax: /SAMODE <#chan/nick> +/-<modes> [parameters for modes]
27 /* $ModDesc: Provides more advanced UnrealIRCd SAMODE command */
31 * Err... not a lot really.
42 class cmd_samode : public command_t
45 cmd_samode (InspIRCd* Instance) : command_t(Instance,"SAMODE", 'o', 2)
47 this->source = "m_samode.so";
48 syntax = "<target> <modes> {<mode-parameters>}";
51 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
54 * Handles an SAMODE request. Notifies all +s users.
57 userrec* n = new userrec(ServerInstance);
58 n->SetFd(FD_MAGIC_NUMBER);
59 ServerInstance->SendMode(parameters,pcnt,n);
62 if (ServerInstance->Modes->GetLastParse().length())
64 ServerInstance->WriteOpers("*** " + std::string(user->nick) + " used SAMODE: " + ServerInstance->Modes->GetLastParse());
66 std::deque<std::string> n;
67 irc::spacesepstream spaced(ServerInstance->Modes->GetLastParse());
68 std::string one = "*";
69 while ((one = spaced.GetToken()) != "")
72 Event rmode((char *)&n, NULL, "send_mode_explicit");
73 rmode.Send(ServerInstance);
76 n.push_back(std::string(user->nick) + " used SAMODE: " + ServerInstance->Modes->GetLastParse());
77 Event rmode2((char *)&n, NULL, "send_opers");
78 rmode2.Send(ServerInstance);
80 /* XXX: Yes, this is right. We dont want to propogate the
81 * actual SAMODE command, just the MODE command generated
82 * by the send_mode_explicit
88 user->WriteServ("NOTICE %s :*** Invalid SAMODE sequence.", user->nick);
95 class ModuleSaMode : public Module
97 cmd_samode* mycommand;
99 ModuleSaMode(InspIRCd* Me)
103 mycommand = new cmd_samode(ServerInstance);
104 ServerInstance->AddCommand(mycommand);
107 virtual ~ModuleSaMode()
111 virtual Version GetVersion()
113 return Version(1,1,2,2,VF_VENDOR,API_VERSION);
118 class ModuleSaModeFactory : public ModuleFactory
121 ModuleSaModeFactory()
125 ~ModuleSaModeFactory()
129 virtual Module * CreateModule(InspIRCd* Me)
131 return new ModuleSaMode(Me);
137 extern "C" void * init_module( void )
139 return new ModuleSaModeFactory;