]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_wallops.cpp
Various text improvements: consistency, syntax, help and doc updates/fixes.
[user/henk/code/inspircd.git] / src / coremods / core_wallops.cpp
index 0210df8ee869d185be7f52e79a38a893d697f2f4..09fafd244146ea329afa7d6d65f25f64bffb2238 100644 (file)
@@ -25,6 +25,7 @@
 class CommandWallops : public Command
 {
        SimpleUserModeHandler wallopsmode;
+       ClientProtocol::EventProvider protoevprov;
 
  public:
        /** Constructor for wallops.
@@ -32,9 +33,10 @@ class CommandWallops : public Command
        CommandWallops(Module* parent)
                : Command(parent, "WALLOPS", 1, 1)
                , wallopsmode(parent, "wallops", 'w')
+               , protoevprov(parent, name)
        {
                flags_needed = 'o';
-               syntax = "<any-text>";
+               syntax = ":<message>";
        }
 
        /** Handle command.
@@ -42,28 +44,46 @@ class CommandWallops : public Command
         * @param user The user issuing the command
         * @return A value from CmdResult to indicate command success or failure.
         */
-       CmdResult Handle(const std::vector<std::string>& parameters, User *user);
+       CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
 
-       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
+       RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                return ROUTE_BROADCAST;
        }
 };
 
-CmdResult CommandWallops::Handle (const std::vector<std::string>& parameters, User *user)
+CmdResult CommandWallops::Handle(User* user, const Params& parameters)
 {
-       std::string wallop("WALLOPS :");
-       wallop.append(parameters[0]);
+       ClientProtocol::Message msg("WALLOPS", user);
+       msg.PushParamRef(parameters[0]);
+       ClientProtocol::Event wallopsevent(protoevprov, msg);
 
        const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
        for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
        {
-               User* t = *i;
-               if (t->IsModeSet(wallopsmode))
-                       t->WriteFrom(user, wallop);
+               LocalUser* curr = *i;
+               if (curr->IsModeSet(wallopsmode))
+                       curr->Send(wallopsevent);
        }
 
        return CMD_SUCCESS;
 }
 
-COMMAND_INIT(CommandWallops)
+class CoreModWallops : public Module
+{
+ private:
+       CommandWallops cmd;
+
+ public:
+       CoreModWallops()
+               : cmd(this)
+       {
+       }
+
+       Version GetVersion() CXX11_OVERRIDE
+       {
+               return Version("Provides the WALLOPS command", VF_CORE | VF_VENDOR);
+       }
+};
+
+MODULE_INIT(CoreModWallops)