mirror of
https://github.com/znc/znc.git
synced 2026-08-07 17:33:34 +02:00
Rework MODE/RPL_CHANMODEIS handling for trailing args (#1661)
Some servers may send a colon even if the last parameter doesn't need it, currently this leads to issues with permission/mode tracking, as the core doesn't handle the colon properly. This fix replaces reconstructing the parameter string with just passing a vector of the relevant parameters to CChan::SetModes() and adds overrides for CChan::SetModes() and CChan::ModeChange() that accept the vector instead. Clean up uses of old CModeMessage::GetModes()
This commit is contained in:
committed by
Alexey Sokolov
parent
51e82fc7e8
commit
95369455fc
@@ -76,8 +76,22 @@ class CChan : private CCoreTranslationMixin {
|
||||
const CString& sHost);
|
||||
|
||||
// Modes
|
||||
/// @deprecated Use SetModes(CString, VCString)
|
||||
void SetModes(const CString& s);
|
||||
/**
|
||||
* Set the current modes for this channel
|
||||
* @param sModes The mode characters being changed
|
||||
* @param vsModeParams The parameters for the modes to be set
|
||||
*/
|
||||
void SetModes(const CString& sModes, const VCString& vsModeParams);
|
||||
/// @deprecated Use ModeChange(CString, VCString, CNick*)
|
||||
void ModeChange(const CString& sModes, const CNick* OpNick = nullptr);
|
||||
/**
|
||||
* Handle changing the modes on a channel
|
||||
* @param sModes The mode string (eg. +ovbs-pbo)
|
||||
* @param vsModeParams The parameters for the mode string
|
||||
*/
|
||||
void ModeChange(const CString& sModes,const VCString& vsModeParams, const CNick* OpNick = nullptr);
|
||||
bool AddMode(char cMode, const CString& sArg);
|
||||
bool RemMode(char cMode);
|
||||
CString GetModeString() const;
|
||||
|
||||
@@ -121,6 +121,18 @@ class CMessage {
|
||||
void SetCommand(const CString& sCommand);
|
||||
|
||||
const VCString& GetParams() const { return m_vsParams; }
|
||||
|
||||
/**
|
||||
* Get a subset of the message parameters
|
||||
*
|
||||
* This allows accessing a vector of a specific range of parameters,
|
||||
* allowing easy inline use, such as `pChan->SetModes(Message.GetParam(2), Message.GetParamsSplit(3));`
|
||||
*
|
||||
* @param uIdx The index of the first parameter to retrieve
|
||||
* @param uLen How many parameters to retrieve
|
||||
* @return A VCString containing the retrieved parameters
|
||||
*/
|
||||
VCString GetParamsSplit(unsigned int uIdx, unsigned int uLen = -1) const;
|
||||
void SetParams(const VCString& vsParams);
|
||||
|
||||
/// @deprecated use GetParamsColon() instead.
|
||||
@@ -257,7 +269,14 @@ REGISTER_ZNC_MESSAGE(CJoinMessage);
|
||||
|
||||
class CModeMessage : public CTargetMessage {
|
||||
public:
|
||||
/// @deprecated Use GetModeList() and GetModeParams()
|
||||
CString GetModes() const { return GetParamsColon(1).TrimPrefix_n(":"); }
|
||||
|
||||
CString GetModeList() const { return GetParam(1); };
|
||||
|
||||
VCString GetModeParams() const { return GetParamsSplit(2); };
|
||||
|
||||
bool HasModes() const { return !GetModeList().empty(); };
|
||||
};
|
||||
REGISTER_ZNC_MESSAGE(CModeMessage);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user