diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-09-04 13:30:01 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-09-04 13:30:01 +0200 |
commit | 3eda212c2ad561fae6a7d8cf20280da9d37a90f4 (patch) | |
tree | ee45d590833690fe46ef56e9fa22641e17ad09b2 /src/modules | |
parent | a1b74f4dfb2393c0baff25101c6366588975fa27 (diff) |
Migrate code from ModeParser into cmd_mode (core_user)
- Process() that takes a std::vector<std::string>
- DisplayCurrentModes()
- DisplayListModes()
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_samode.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp index 63d4f7622..caf1f27c4 100644 --- a/src/modules/m_samode.cpp +++ b/src/modules/m_samode.cpp @@ -52,11 +52,27 @@ class CommandSamode : public Command if (!user->HasPrivPermission("users/samode-usermodes", true)) return CMD_FAILURE; } + + // XXX: Make ModeParser clear LastParse + Modes::ChangeList emptychangelist; + ServerInstance->Modes->ProcessSingle(ServerInstance->FakeClient, NULL, ServerInstance->FakeClient, emptychangelist); + this->active = true; - ServerInstance->Parser.CallHandler("MODE", parameters, user); - if (ServerInstance->Modes->GetLastParse().length()) - ServerInstance->SNO->WriteGlobalSno('a', user->nick + " used SAMODE: " +ServerInstance->Modes->GetLastParse()); + CmdResult result = ServerInstance->Parser.CallHandler("MODE", parameters, user); this->active = false; + + if (result == CMD_SUCCESS) + { + // If lastparse is empty and the MODE command handler returned CMD_SUCCESS then + // the client queried the list of a listmode (e.g. /SAMODE #chan b), which was + // handled internally by the MODE command handler. + // + // Viewing the modes of a user or a channel can also result in CMD_SUCCESS, but + // that is not possible with /SAMODE because we require at least 2 parameters. + const std::string& lastparse = ServerInstance->Modes.GetLastParse(); + ServerInstance->SNO->WriteGlobalSno('a', user->nick + " used SAMODE: " + (lastparse.empty() ? irc::stringjoiner(parameters) : lastparse)); + } + return CMD_SUCCESS; } }; |