- this->AddMode(new ModeUserServerNotice, 's');
- this->AddMode(new ModeUserWallops, 'w');
- this->AddMode(new ModeUserInvisible, 'i');
- this->AddMode(new ModeUserOperator, 'o');
- this->AddMode(new ModeUserServerNoticeMask, 'n');
+ this->AddMode(new ModeUserServerNotice(Instance), 's');
+ this->AddMode(new ModeUserWallops(Instance), 'w');
+ this->AddMode(new ModeUserInvisible(Instance), 'i');
+ this->AddMode(new ModeUserOperator(Instance), 'o');
+ this->AddMode(new ModeUserServerNoticeMask(Instance), 'n');
+}
+
+bool ModeParser::InsertMode(std::string &output, const char* mode, unsigned short section)
+{
+ unsigned short currsection = 1;
+ unsigned int pos = output.find("CHANMODES=", 0) + 10; // +10 for the length of "CHANMODES="
+
+ if(section > 4 || section == 0)
+ {
+ log(DEBUG, "InsertMode: CHANMODES doesn't have a section %dh :/", section);
+ return false;
+ }
+
+ for(; pos < output.size(); pos++)
+ {
+ if(section == currsection)
+ break;
+
+ if(output[pos] == ',')
+ currsection++;
+ }
+
+ output.insert(pos, mode);
+ return true;