class CommandWallops : public Command
{
SimpleUserModeHandler wallopsmode;
+ ClientProtocol::EventProvider protoevprov;
public:
/** Constructor for wallops.
CommandWallops(Module* parent)
: Command(parent, "WALLOPS", 1, 1)
, wallopsmode(parent, "wallops", 'w')
+ , protoevprov(parent, name)
{
flags_needed = 'o';
syntax = "<any-text>";
* @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);
- for (LocalUserList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++)
+ 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)