summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mode.h11
-rw-r--r--src/mode.cpp24
-rw-r--r--src/modules/m_samode.cpp15
3 files changed, 39 insertions, 11 deletions
diff --git a/include/mode.h b/include/mode.h
index fe646c9b3..070b89a95 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -360,6 +360,11 @@ class ModeParser : public classbase
*/
void DisplayCurrentModes(userrec *user, userrec* targetuser, chanrec* targetchannel, const char* text);
+ /** The string representing the last set of modes to be parsed.
+ * Use GetLastParse() to get this value, to be used for display purposes.
+ */
+ std::string LastParse;
+
public:
/** The constructor initializes all the RFC basic modes by using ModeParserAddMode().
@@ -390,6 +395,12 @@ class ModeParser : public classbase
* This method can be used on both IPV4 and IPV6 user masks.
*/
static void CleanMask(std::string &mask);
+ /** Get the last string to be processed, as it was sent to the user or channel.
+ * Use this to display a string you just sent to be parsed, as the actual output
+ * may be different to what you sent after it has been 'cleaned up' by the parser.
+ * @return Last parsed string, as seen by users.
+ */
+ const std::string& GetLastParse();
/** Add a mode to the mode parser. The modeletter parameter
* is purely to save on doing a lookup in the function, as
* strictly it could be obtained via ModeHandler::GetModeChar().
diff --git a/src/mode.cpp b/src/mode.cpp
index f74a2ac60..ddc2d4d16 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -509,10 +509,18 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
if (type == MODETYPE_CHANNEL)
{
targetchannel->WriteChannelWithServ(ServerInstance->Config->ServerName, "MODE %s %s%s", targetchannel->name, output_sequence.c_str(), parameter_list.str().c_str());
+ this->LastParse = targetchannel->name;
+ LastParse.append(" ");
+ LastParse.append(output_sequence);
+ LastParse.append(parameter_list.str());
}
else
{
targetuser->WriteServ("MODE %s %s%s",targetuser->nick,output_sequence.c_str(), parameter_list.str().c_str());
+ this->LastParse = targetuser->nick;
+ LastParse.append(" ");
+ LastParse.append(output_sequence);
+ LastParse.append(parameter_list.str());
}
}
else
@@ -522,17 +530,30 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
ServerInstance->Log(DEBUG,"Write output sequence and parameters to channel: %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
targetchannel->WriteChannel(user,"MODE %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
FOREACH_MOD(I_OnMode,OnMode(user, targetchannel, TYPE_CHANNEL, output_sequence + parameter_list.str()));
+ this->LastParse = targetchannel->name;
+ LastParse.append(" ");
+ LastParse.append(output_sequence);
+ LastParse.append(parameter_list.str());
}
else
{
user->WriteTo(targetuser,"MODE %s %s%s",targetuser->nick,output_sequence.c_str(), parameter_list.str().c_str());
FOREACH_MOD(I_OnMode,OnMode(user, targetuser, TYPE_USER, output_sequence));
+ this->LastParse = targetuser->nick;
+ LastParse.append(" ");
+ LastParse.append(output_sequence);
+ LastParse.append(parameter_list.str());
}
}
}
}
}
+const std::string& ModeParser::GetLastParse()
+{
+ return LastParse;
+}
+
void ModeParser::CleanMask(std::string &mask)
{
std::string::size_type pos_of_pling = mask.find_first_of('!');
@@ -905,6 +926,9 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance)
memset(modehandlers, 0, sizeof(modehandlers));
memset(modewatchers, 0, sizeof(modewatchers));
+ /* Last parse string */
+ LastParse = "";
+
/* Initialise the RFC mode letters */
/* Start with channel simple modes, no params */
diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp
index 95c13f69a..781875594 100644
--- a/src/modules/m_samode.cpp
+++ b/src/modules/m_samode.cpp
@@ -54,21 +54,14 @@ class cmd_samode : public command_t
/*
* Handles an SAMODE request. Notifies all +s users.
*/
- std::string result;
- ServerInstance->Log(DEBUG,"SAMODE: Being handled");
+
userrec* n = new userrec(ServerInstance);
n->SetFd(FD_MAGIC_NUMBER);
ServerInstance->SendMode(parameters,pcnt,n);
delete n;
- ServerInstance->Log(DEBUG,"SAMODE: Modechange handled");
- result = std::string(user->nick);
- result.append(" used SAMODE");
- for (int n = 0; n < pcnt; n++)
- {
- result.append(" ");
- result.append(parameters[n]);
- }
- ServerInstance->WriteOpers(result);
+
+ if (ServerInstance->Modes->GetLastParse().length())
+ ServerInstance->WriteOpers(std::string(user->nick)+" used SAMODE: "+ServerInstance->Modes->GetLastParse());
return CMD_SUCCESS;
}