summaryrefslogtreecommitdiff
path: root/src/modules/m_operjoin.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-02-11 14:08:11 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-02-11 14:08:11 +0100
commitc77cc4f737c782c3a56d69da0eac82edd41d4976 (patch)
treef540660ed13c5c95266ef16e4453f0fcd11f8cb8 /src/modules/m_operjoin.cpp
parent87ce845b68a1a0314b3ce5dd61ee386f744b2f85 (diff)
m_operjoin Remove duplicated code
Diffstat (limited to 'src/modules/m_operjoin.cpp')
-rw-r--r--src/modules/m_operjoin.cpp42
1 files changed, 8 insertions, 34 deletions
diff --git a/src/modules/m_operjoin.cpp b/src/modules/m_operjoin.cpp
index 8a5041190..dd80d99ba 100644
--- a/src/modules/m_operjoin.cpp
+++ b/src/modules/m_operjoin.cpp
@@ -26,39 +26,20 @@
class ModuleOperjoin : public Module
{
- std::string operChan;
std::vector<std::string> operChans;
bool override;
- int tokenize(const std::string &str, std::vector<std::string> &tokens)
- {
- // skip delimiters at beginning.
- std::string::size_type lastPos = str.find_first_not_of(",", 0);
- // find first "non-delimiter".
- std::string::size_type pos = str.find_first_of(",", lastPos);
-
- while (std::string::npos != pos || std::string::npos != lastPos)
- {
- // found a token, add it to the vector.
- tokens.push_back(str.substr(lastPos, pos - lastPos));
- // skip delimiters. Note the "not_of"
- lastPos = str.find_first_not_of(",", pos);
- // find next "non-delimiter"
- pos = str.find_first_of(",", lastPos);
- }
- return tokens.size();
- }
-
public:
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
ConfigTag* tag = ServerInstance->Config->ConfValue("operjoin");
- operChan = tag->getString("channel");
override = tag->getBool("override", false);
+ irc::commasepstream ss(tag->getString("channel"));
operChans.clear();
- if (!operChan.empty())
- tokenize(operChan,operChans);
+
+ for (std::string channame; ss.GetToken(channame); )
+ operChans.push_back(channame);
}
Version GetVersion() CXX11_OVERRIDE
@@ -76,18 +57,11 @@ class ModuleOperjoin : public Module
if (ServerInstance->IsChannel(*i))
Channel::JoinUser(localuser, *i, override);
- std::string chanList = localuser->oper->getConfig("autojoin");
- if (!chanList.empty())
+ irc::commasepstream ss(localuser->oper->getConfig("autojoin"));
+ for (std::string channame; ss.GetToken(channame); )
{
- std::vector<std::string> typechans;
- tokenize(chanList, typechans);
- for (std::vector<std::string>::const_iterator it = typechans.begin(); it != typechans.end(); ++it)
- {
- if (ServerInstance->IsChannel(*it))
- {
- Channel::JoinUser(localuser, *it, override);
- }
- }
+ if (ServerInstance->IsChannel(channame))
+ Channel::JoinUser(localuser, channame, override);
}
}
};